Hello all,
I have an asp:dropdownlist that is dynamically filled with a query.
This part is working. The problem I have is when I change the item in
the dropdown list and submit my form, the value for the dropdown list
never changes. It always inserts the value of the first item in the
list.
Here is my dropdown:
<asp:DropDownList ID="CallReason" DataTextField="call_reason"
DataValueField="id" runat="server" />
Here is the code behind:
cmd2.CommandText = "SELECT id, call_reason FROM <TABLE>";
qlDataReader rdr = null;
cn.ConnectionString = constants.ConnectionString;
cn.Open();
cmd.Connection = cn;
objAcc.Fill_DataReader(cmd2, ref rdr);
CallReason.DataSource = rdr;
CallReason.DataBind();
Can someone tell me what I am doing wrong here?
Thanks.
DCW - 28 Mar 2007 22:44 GMT
You are rebinding the list and losing dropdown's persisted value. Only bind
the first time (!IsPostBack) and you'll be good.
Drew
> Hello all,
>
[quoted text clipped - 24 lines]
>
> Thanks.