Here's my function:
public void getInterestLevelDDL(string co_interest_level)
{
sql = [valid sql];
//get_select_list creates a valid ICollection datatable
ctrlDDL_CIL.DataSource = tools.get_select_list(sql);
ctrlDDL_CIL.DataTextField = "value";
ctrlDDL_CIL.DataValueField = "key";
try
{
ctrlDDL_CIL.SelectedValue = co_interest_level;
ctrlDDL_CIL.DataBind();
}
catch
{
ctrlDDL_CIL.SelectedValue = "0";
ctrlDDL_CIL.DataBind();
}
}
If co_interest_level is in the range of dropdownlist values, I've no
problems. However, sometimes it's not, but I can't seem to get the code
to return a default gracefully. This example fails on the second
DataBind() with the error "Specified argument was out of the range of
valid values. Parameter name: value". However, the value "0" is ALWAYS
in the list, as I've made it part of the get_select_list return value.
Also, I've tried a ClearSelection(), but that doesn't seem to do a thing...
I'd sure appreciate any help!
--Brent