I use LinqDataSource with a Repeater control to retrieve and show data depends on DropDownList SelectedValue.
my Code follows -
protected void Button1_Click(object sender, EventArgs e)
{
Repeater1.DataBind();
}
protected void DropDownList1_DataBound(object sender, EventArgs e)
{
DropDownList1.Items.Insert(0, "--");
}
protected void LinqDataSource1_Selecting(object sender, LinqDataSourceSelectEventArgs e)
{
if (DropDownList1.SelectedValue != "--")
{
e.WhereParameters.Add("city", DropDownList1.SelectedValue);
}
}
When form is loaded I get all the records as expected but when I change DropDownList1 SelectedValue (select a specific city) and than click Button1 I get the same results, that is all the records
Do I need to change anything in my LinqDataSource1_Selecting method ?