R
Randy Armknecht
The problem is that when the SelectedIndex is changed, it posts back the
page. It does not however fire the OnSelectedIndexChanged event, and it
does NOT keep the state of the item that was selected in the DDL.
DropDownList looks like this:
<asp:dropdownlist id="DropDown" Runat="server"
AutoPostBack="True"></asp:dropdownlist>
The EventHandler Setup looks like this:
private void InitializeComponent()
{
this.DropDown.SelectedIndexChanged += new
System.EventHandler(this.DropDown_SelectedIndexChanged);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
protected void DropDown_SelectedIndexChanged(object sender,
System.EventArgs e)
{
//Response.Redirect(DropDown.SelectedValue);
Response.Write("CAT");
}
Here's the Page_Load code:
if(!Page.IsPostBack)
{
fillDropDown();
}
if (Page.IsPostBack)
{
//Response.Redirect(DropDown.SelectedValue);
Response.Write(this.DropDown.SelectedItem.Text);
}
As you can tell from these snipets, I'm not doing anything crazy or
overly complex. All I want is the value of the DropDownItem that was
Selected.
**Please note that Response.Write(this.DropDown.SelectedItem.Text) was
used in the page_load to simply get something to display on the screen
as the first item loaded into the DDL has text only and no value
Any help in resolving this is greatly appreciated.
-Randy
page. It does not however fire the OnSelectedIndexChanged event, and it
does NOT keep the state of the item that was selected in the DDL.
DropDownList looks like this:
<asp:dropdownlist id="DropDown" Runat="server"
AutoPostBack="True"></asp:dropdownlist>
The EventHandler Setup looks like this:
private void InitializeComponent()
{
this.DropDown.SelectedIndexChanged += new
System.EventHandler(this.DropDown_SelectedIndexChanged);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
protected void DropDown_SelectedIndexChanged(object sender,
System.EventArgs e)
{
//Response.Redirect(DropDown.SelectedValue);
Response.Write("CAT");
}
Here's the Page_Load code:
if(!Page.IsPostBack)
{
fillDropDown();
}
if (Page.IsPostBack)
{
//Response.Redirect(DropDown.SelectedValue);
Response.Write(this.DropDown.SelectedItem.Text);
}
As you can tell from these snipets, I'm not doing anything crazy or
overly complex. All I want is the value of the DropDownItem that was
Selected.
**Please note that Response.Write(this.DropDown.SelectedItem.Text) was
used in the page_load to simply get something to display on the screen
as the first item loaded into the DDL has text only and no value
Any help in resolving this is greatly appreciated.
-Randy