I am unable bind value from the list to the textbox after SelectedIndexChanged event. The dropboxlist has AutoPostBack=true. But it doesn't fire this event
<asp:DropDownList ID="ddlRSM" runat="server" AutoPostBack="true">
</asp:DropDownList>
The DropdownList is loaded from C# code method
private void GetRMS(string _ct, DropDownList ddl)
{
SPWeb web = SPContext.Current.Web;
// web = SPContext.Current.Site.OpenWeb("myteam");
SPUser currentUser = web.CurrentUser;
SPQuery query = new SPQuery();
SPList list = web.Lists.TryGetList("RSM");
string strQuery = string.Empty;
strQuery = "<FieldRef Name='Title'/>";
strQuery += "<Where><Eq><FieldRef Name='CustomerType'/><Value Type='Choice'>{0}</Value></Eq></Where>";
strQuery = string.Format(strQuery, _ct);
query.Query = strQuery;
DataTable dt = list.GetItems(query).GetDataTable();
ddl.DataSource = dt;
ddl.DataTextField = "Title";
ddl.DataValueField = "Title";
ddl.DataBind();
ddl.Items.Insert(0, "<-- Select " + _ct + " -->");
ddl.SelectedIndex = 0;
int idx = ddl.SelectedIndex;
}
and this is the event which is not triggered
protected void ddl_SelectedIndexChanged(object sender, EventArgs e)
{
string _ct = ddlRSM.SelectedItem.Text;
SPWeb web = SPContext.Current.Web;
SPQuery query = new SPQuery();
SPList list = web.Lists.TryGetList("myList");
string strQuery = string.Empty;
strQuery = "<FieldRef Name='Address'/>";
strQuery += "<Where><Eq><FieldRef Name='Title'/><Value Type='Text'>{0}</Value></Eq></Where>";
strQuery = string.Format(strQuery, _ct);
query.Query = strQuery;
SPListItemCollection items = list.GetItems(strQuery);
tbShipTo.Text = items[items.Count - 1]["Address"].ToString();
}