Hi
I have a lstCentre in dropdown and txtOnDate as datepicker.
Based on these values the grid should display data.
I am using Linqdatasource with where clause
I tried all the following:
1. Where="Centre == @Centre && ExpectedDate == (DateTime.Parse(@ExpectedDate))"
2. Where="Centre == @Centre && (DateTime.Parse(ExpectedDate)) == @ExpectedDate"
3. Where="Centre == @Centre && ExpectedDate == Convert.ToDateTime(@ExpectedDate)"
None of them work and give me error as shown in screen shot attached.
Below is the code:
Please help me.
Thanks in advance..
S
I have a lstCentre in dropdown and txtOnDate as datepicker.
Based on these values the grid should display data.
I am using Linqdatasource with where clause
I tried all the following:
1. Where="Centre == @Centre && ExpectedDate == (DateTime.Parse(@ExpectedDate))"
2. Where="Centre == @Centre && (DateTime.Parse(ExpectedDate)) == @ExpectedDate"
3. Where="Centre == @Centre && ExpectedDate == Convert.ToDateTime(@ExpectedDate)"
None of them work and give me error as shown in screen shot attached.
Below is the code:
Visitors.aspx
******************************************************************
<
li
>
<
asp:Label
ID
=
"lbCentre"
runat
=
"server"
Text
=
"Centre:"
AssociatedControlID
=
"lstCentre"
></
asp:Label
><
telerik:RadComboBox
ID
=
"lstCentre"
runat
=
"server"
AppendDataBoundItems
=
"True"
DataSourceID
=
"LinqCentre"
DataTextField
=
"Centre"
DataValueField
=
"Centre"
DataKeyField
=
"Centre"
DataSortField
=
"Centre"
ReadOnly
=
"true"
CausesValidation
=
"False"
onselectedindexchanged
=
"lstCentre_SelectedIndexChanged"
AutoPostBack
=
"true"
><
Items
><
telerik:RadComboBoxItem
Text
=
"Choose One..."
Value
=
"10"
/></
Items
></
telerik:RadComboBox
>
</
li
><
li
></
li
>
<
li
><
asp:Label
ID
=
"lbOnDate"
runat
=
"server"
Text
=
"On (Date):"
AssociatedControlID
=
"txtOnDate"
></
asp:Label
>
<
telerik:RadDatePicker
ID
=
"txtOnDate"
runat
=
"server"
DateFormat
=
"dd/MM/yyyy"
Enabled
=
"true"
Culture
=
"English (United Kingdom)"
AutoPostBack
=
"true"
onselecteddatechanged
=
"txtOnDate_SelectedDateChanged"
></
telerik:RadDatePicker
>
</
li
>
<
asp:LinqDataSource
ID
=
"LinqVisitors"
runat
=
"server"
ContextTypeName
=
"CWC.Staffnet.Forms.StaffnetDataContext"
TableName
=
"tblVisitors"
Where
=
"Centre == @Centre && ExpectedDate == (DateTime.Parse(@ExpectedDate))"
onselecting
=
"LinqVisitors_Selecting"
>
<
WhereParameters
>
<
asp:ControlParameter
ControlID
=
"lstCentre"
Name
=
"Centre"
PropertyName
=
"SelectedValue"
Type
=
"String"
/>
<
asp:ControlParameter
ControlID
=
"txtOnDate"
Name
=
"ExpectedDate"
PropertyName
=
"SelectedDate"
Type
=
"DateTime"
/>
</
WhereParameters
>
</
asp:LinqDataSource
>
*****************************************************
Visitors.aspx.cs
*****************************************************
protected void LinqVisitors_Selecting(object sender, LinqDataSourceSelectEventArgs e)
{
foreach (KeyValuePair<
string
, object> kvp in e.WhereParameters)
{
if (kvp.Value == null)
{ e.Cancel = true; return; }
}
}
Please help me.
Thanks in advance..
S