T
tshad
If I have a dropdown that is going to repopulate, I want to be able to put
the selection back (if it is still there).
For example:
oldValue = ddlClient.SelectedValue;
GetClientNames();
ddlClient.Items.FindByValue(oldValue).Selected = true;
This works fine if the selection is still there. If not you get an Object
not there error.
If you do this:
oldValue = ddlClient.SelectedValue;
GetClientNames();
if(ddlClient.Items.FindByValue(oldValue) != null)
ddlClient.Items.FindByValue(oldValue).Selected = true;
You get a multiple selection error.
Does the if statement actually select it so that I can actually do:
oldValue = ddlClient.SelectedValue;
GetClientNames();
ddlClient.Items.FindByValue(oldValue);
and it will select it if there, otherwise be at the 1st item in the list.
If so, then I assume that the following statement is really never a good
idea:
ddlClient.Items.FindByValue(oldValue).Selected = true;
Am I right here?
Thanks,
Tom
the selection back (if it is still there).
For example:
oldValue = ddlClient.SelectedValue;
GetClientNames();
ddlClient.Items.FindByValue(oldValue).Selected = true;
This works fine if the selection is still there. If not you get an Object
not there error.
If you do this:
oldValue = ddlClient.SelectedValue;
GetClientNames();
if(ddlClient.Items.FindByValue(oldValue) != null)
ddlClient.Items.FindByValue(oldValue).Selected = true;
You get a multiple selection error.
Does the if statement actually select it so that I can actually do:
oldValue = ddlClient.SelectedValue;
GetClientNames();
ddlClient.Items.FindByValue(oldValue);
and it will select it if there, otherwise be at the 1st item in the list.
If so, then I assume that the following statement is really never a good
idea:
ddlClient.Items.FindByValue(oldValue).Selected = true;
Am I right here?
Thanks,
Tom