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,239 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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
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…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

785 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