Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2011-09-26
4
Medium Priority
?
1,317 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …

670 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