Home > DeveloperSection > Forums > SelectedValue of DropDownList is not the one I selected when Enabled=false
Mark Devid
Mark Devid

Total Post:102

Posted on    August-27-2014 1:58 AM


 1 Reply(s)
 847  View(s)
Rate this:

I have a few DropDownLists on a webform each pointing to a SqlDataSource. Some of these datasources use one of these DropDownLists for a select parameter, filtering the list to specific categories.

For certain users two of these DropDownLists are to be automatically set and disabled.

When I submit the form with the drop downs enabled it works fine but when they are disabled the SelectedValue of the DropDownList is being reset to the first one in the list.


<asp:DropDownList ID="ddlManager" runat="server" DataSourceID="dsManagers"

  EnableViewState="false" DataValueField="ManagerID" DataTextField="MgrName"

  AppendDataBoundItems="false" ondatabound="ddlManager_DataBound" >

The drop down lists add an extra item on the data bound event as follows:


protected void ddlManager_DataBound(object sender, EventArgs e)


  this.ddlManager.Items.Insert(0, new ListItem("--Manager--", "--Manager--"));


Sumit Kesarwani

Total Post:378

Posted on    August-27-2014 11:18 PM

Hi Mark, 

You can read/write to a List<> or Dictionary<>; and assign the list to your DropDownList datasource whenever the DropDownList box gets enabled.

Don't want to miss updates? Please click the below button!

Follow MindStick