I have a Dropdownlist (System.Web.UI.WebControls.DropDownList) which I Bind during the pageload.
try
{
if (!Page.IsPostBack)
{
DataTable dt = new StaticNoticeController().GetStaticNoticeNames();
this.HeadingsDropDownList.AutoPostBack = true;
this.HeadingsDropDownList.DataSource = new StaticNoticeController().GetStaticNoticeNames();
this.HeadingsDropDownList.DataTextField = "NoticeName";
this.HeadingsDropDownList.DataValueField = "NoticeId";
this.HeadingsDropDownList.DataBind();
}
}
catch (SystemException ex)
{
//ToDo: Log the Exception
}
I expect the SelectedIndex event to get fired when I bind the dropdown to a combobox ( which use to happen in case of Comboboxes in Winforms ) so that the page is loaded with values corresponding to the initial value in the dropdown list.
I even tried
this.HeadingsDropDownList.selectedIndex = -1;
in pageload after databind. But in vain .
When I change the index of the dropdown through the browser , the event gets fired as usual.
Am I missing something or am I trying to perform something which is not possible ?
Please help.
Thanks in Advance
It would essentially mean that when you load the site it would directly postback. It would be stuck in a loop.
If its an inited value, then what the postback would do should be done in the init.