Solved

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

Posted on 2011-09-26
4
1,205 Views
Last Modified: 2012-05-12
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
Comment
Question by:johngrant_ks
  • 2
4 Comments
 
LVL 12

Expert Comment

by:jagssidurala
ID: 36702294
Try this

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

this is in vb.net


0
 
LVL 13

Expert Comment

by:jonnidip
ID: 36707567
Is this what you mean?
... SomeDate = new DateTime(2011,11,11)...

Regards.
0
 

Accepted Solution

by:
johngrant_ks earned 0 total points
ID: 36713862
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
 

Author Closing Comment

by:johngrant_ks
ID: 36899009
Answered my own question
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now