• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1401
  • Last Modified:

How can I programatically set the where parameter of a LINQ DataSource control for a datetime Type?

Hi

How can I programatically set the where parameter of a LINQ DataSource control for a datetime Type?

Have tried thses but no luck

LinqDataSource1.Where = "SomeDate = 11/11/2001";

LinqDataSource1.Where = "SomeDate = @SomeDate";
LinqDataSource1.WhereParameters.Add("SomeDate", DbType.DateTime, "11/11/2001");

LinqDataSource1.WhereParameters["SomeDate"].DefaultValue = "11/11/2001";
0
johngrant_ks
Asked:
johngrant_ks
  • 2
1 Solution
 
jagssiduralaCommented:
Try this

Dim objFilterdata = From objSource in LinqDataSource1 Where objSource.SomeDate = "11/11/2001"

this is in vb.net


0
 
jonnidipCommented:
Is this what you mean?
... SomeDate = new DateTime(2011,11,11)...

Regards.
0
 
johngrant_ksAuthor Commented:
Thanks For the help

This i s what eventually fixed the problem it was alot to do with the format of the date yyyy-MM-dd



 
StringBuilder whereClause = new StringBuilder();

 DateTime datDatePurchase = Convert.ToDateTime(DateControl8.wctxtDateControl.Text.HtmlEncode().ToString());
            whereClause.Append("DatePurchased >= DateTime.Parse(\"" + datDatePurchase.ToString("yyyy-MM-dd") + "\")");

LinqDataSource1.Where = whereClause.ToString();

Open in new window

0
 
johngrant_ksAuthor Commented:
Answered my own question
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now