Setting LinqDataSource Binding to DropDownList Using URL Request
This is a puzzle for me, I can get the three DropDownLists to behave like a cascade (it fetches the correct data), but where I run into a problem, I am trying to set the value for the dropdown based on the request value.
Only the first dropdownlist seems to take the value from the query string. The other two don't. In fact, the third DropDownlist will also show the error below (it almost looks like the control is not linked yet:
'ddlStation' has a SelectedValue which is invalid because it does not exist in the list of items.
Parameter name: value
FYI, here's the part that sets the DropDownList to the Page_Load event:
// see if there is any querystring and set dropdownlist accordingly
if (Request.QueryString["cell"] != null)
{
ddlCell.SelectedValue = Request.QueryString["cell"].ToString();
if (Request.QueryString["subcell"] != null)
{
ddlSubCell.SelectedValue = Request.QueryString["subcell"].ToString();
if (Request.QueryString["station"] != null)
{
ddlStation.SelectedValue = Request.QueryString["station"].ToString();
}
}
}
Any help is appreciated!
+1
source to share
2 answers