Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 660801
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T23:11:49+00:00 2026-05-13T23:11:49+00:00

On an ASP.NET web page I have an EntityDataSource: <asp:EntityDataSource ID=EntityDataSourceOrders runat=server ConnectionString=name=EntitiesContext DefaultContainerName=EntitiesContext

  • 0

On an ASP.NET web page I have an EntityDataSource:

<asp:EntityDataSource ID="EntityDataSourceOrders" runat="server" 
        ConnectionString="name=EntitiesContext"
        DefaultContainerName="EntitiesContext" 
        EntitySetName="Order" 
        Select="it.OrderID,it.OrderCode,it.OrderDateTime"
        Where="it.OrderDateTime &gt;= @DateTimeFrom AND it.OrderDateTime &lt;= @DateTimeTo"
        OrderBy="it.SOrderCode"
        StoreOriginalValuesInViewState="False" >
        <WhereParameters>
            <asp:ControlParameter Name="DateTimeFrom" 
                                  ControlID="TextBoxDateTimeFrom"
                                  DbType="DateTime"
                                  PropertyName="Text" />
            <asp:ControlParameter Name="DateTimeTo"
                                  ControlID="TextBoxDateTimeTo"
                                  DbType="DateTime"
                                  PropertyName="Text" />
        </WhereParameters>
</asp:EntityDataSource>

As you can see there are two Textboxes on the page to enter an earliest and latest date for my selection. These Textboxes are used as ControlParameters in Where-clause of the EntityDataSource.

Now imagine someone enters an invalid date like “32/01/2010” in one of those ControlParameter textboxes.

I am aware that I can validate at first on client side (using the ASP.NET validators), so I prevent a postback if the input is invalid.

But how do I implement the more important “final” validation on server side? Especially WHERE (which method or event) do I implement it to prevent the EntityDataSource to execute the query with invalid DateTime values in the Textboxes?

Basically my idea was to call something like Page.Validate() and then Page.IsValid and, if IsValid returns false, to “cancel” the EntityDataSource query execution (or prevent it to start at all). But I don’t know where or in which event I can hook up into the EntityDataSource to prevent the query execution.

Perhaps I am thinking into the wrong direction. Does somebody have an idea what to do?

Thank you in advance for help!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T23:11:49+00:00Added an answer on May 13, 2026 at 11:11 pm

    It’s not the responsibility of the EntityDataSource to check for validity. When you have a ‘save’ button on the page, the code behind the button click can check for Page.IsValid. When you are working with standard ASP.NET controls, such as the GridView, those controls will call Page.IsValid for you.

    So in your situation, I’d go with ASP.NET validation controls on the page. They will also run on the server side.

    [Update]

    You can hook-up a method to the EntityDataSource.Selecting event and set the Cancel property of the EntityDataSourceSelectingEventArgs to true when the page is not valid.

    private void EntityDataSourceOrders_Selecting(
        object sender, EntityDataSourceSelectingEventArgs e)
    {
        e.Cancel = !this.Page.IsValid;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 449k
  • Answers 449k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer On a unix system I'd probably utilise a shared memory… May 15, 2026 at 8:22 pm
  • Editorial Team
    Editorial Team added an answer Are you only referring to the text fading and sliding… May 15, 2026 at 8:22 pm
  • Editorial Team
    Editorial Team added an answer Try: canvas.drawRect(30,0,35,50,Reference_to_Paint_Object); This is assuming that you want the rectangle… May 15, 2026 at 8:22 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.