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 7415411
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T07:17:54+00:00 2026-05-29T07:17:54+00:00

I have a gridview that is populated from an entitydatasource in asp.net. In my

  • 0

I have a gridview that is populated from an entitydatasource in asp.net. In my c# code-behind I need to add a WHERE parameter to the entity data source that will filter out all data that is not >= validDate1 and <= validDate2.

Here is where I’m at:

using (RamRideOpsEntities myEntities = new RamRideOpsEntities())
{
    var validDates = (from a in myEntities.AdminOptions
                      select new { a.ValidDate1, a.ValidDate2 }).FirstOrDefault();

    if (validDates != null)
    {
         RidesGridView.Where = "  ..... ??? " //TODO
    }
}

Edit: with the answers below, let me be more clear.. the validDates = …. statement is just getting the two valid dates I need to filter by.. there ‘where’ clause needs to be added to the entity data source so the data displayed in the grid view is within the valid date range.

  • 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-29T07:17:55+00:00Added an answer on May 29, 2026 at 7:17 am

    You’re using an EntityDataSource. This is a very un-linq type which allows you to use runtime-defined strings to modify queries. A more linq-ish technique would prefer that the string is part of the language of the program, and the compiler would turn it into an expression tree (as others have posted). That linq-ish approach won’t work as long as you’re using an EntityDataSource.

    From the msdn article referencing EntityDataSource.Where, it looks like you need to use the magic word “it” to describe the row. Then you’d supply the parameters to the .WhereParameters collection.

    Code:

    using (myEntities = new RamRideOpsEntities())
    {
          var validDates = (from a in myEntities.AdminOptions
                            select new { a.ValidDate1, a.ValidDate2 }).FirstOrDefault();
    
          if (validDates != null)
          {
             RidesEDS.Where = @"it.TimeOfCall >= @ValidDate1 AND it.TimeOfCall <= @ValidDate2";
             RidesEDS.WhereParameters.Add(@"ValidDate1", DbType.DateTime, validDates.ValidDate1.ToString());
             RidesEDS.WhereParameters.Add(@"ValidDate2", DbType.DateTime, validDates.ValidDate2.ToString());
          }
     }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a GridView that gets populated with data from a SQL database, very
I have a GridView that I need to dynamically add TemplateField elements to. My
i have populated gridview from SaleDAL class, assuming following is the code, Please ignore
I have a gridview that imports data from a remote database, this is working
I have a gridview that is being populated from a datasouce. The Stored procedure
I have a GridView being populated from a non-SQL database that we use internally.
I have a page with a gridview that is populated from a sql. The
I have a gridview that is bound to a datasource (Windows Forms, VB.NET). One
I have a gridview that contains value of every rows read from a text
Basically, I have a gridview that is opened in a new window from the

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.