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 490k
  • Answers 490k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

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

    • 7 Answers
  • Editorial Team

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

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You most likely skipped over the step where you need… May 16, 2026 at 9:10 am
  • Editorial Team
    Editorial Team added an answer KBDLLHOOKSTRUCT *kbdStruct = (KBDLLHOOKSTRUCT*)lParam; :) May 16, 2026 at 9:10 am
  • Editorial Team
    Editorial Team added an answer The following prints "A::foo C::bar" as expected. Are you getting… May 16, 2026 at 9:10 am

Trending Tags

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

Top Members

Related Questions

I have an ASP.Net web page, which uses a Master Page template. The page
I have an ASP.NET web page that displays a variety of fields that need
I have an asp.net web page written in C#. Using some javascript I popup
I have an ASP.NET web page with a Login control on it. When I
(ASP.net 3.5, C#, SQL Express 2008) I want to have a Web Form, where
I am setting up an asp.net web parts portal for some stuff. I have
The old ASP.NET ASMX Web services used to produce a Web page that allowed
I ran into this dilemma when working on an ASP.net web application using Web
I have two SQL Server tables with Primary Keys (PK) and a Foreign Key

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.