Search code examples
c#asp.netsqlwebformslinqdatasource

GridView LinqDataSource and Calendar controls


This is seemingly easy task and yet I can't get this to worl so please give me your pointers. I have a SQL table that has one of its columns of DateTime type. I want to access it from ASP application via LinqDataSource. I want to provide WHERE parameter to LinqDataSourcefrom Calendarcontrol (that returns DateTime as SelectedDate). I want to display set in GridView. Seems easy, doesn't it? But regardless of what I do I get an error at runtime:

Operator '==' can not be applied to operands of type DateTime and Object which makes no sense to me because Calendar returns DateTime and LINQ class also returns DateTime for that column. How would you approach this task or this problem. I can't use SqlDataSource because of SQL served and IIS security configuration that currently I do not want to touch.


Solution

  • Unfortunatelly it is impossible to perform this wiring declaratively. Instead load your query with filters into a List<>)_ and bind GridView to it in C# code.