欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

DropDownList獲取的SelectIndex一直為0的問題

 更新時間:2014年06月05日 16:33:31   作者:  
由于初始化判斷出錯導致每次傳到服務器的時候會初始化一次,這就導致每次獲取DropDownList的SelectIndex的時候只能是0
1.想要DropDownList自動提交必須設置AutoPostBack="true"屬性,下面是代碼:
復制代碼 代碼如下:

<asp:DropDownList ID="ddlNameList" runat="Server" Height="30"
AutoPostBack="True" onselectedindexchanged="ddlNameList_SelectedIndexChanged" ></asp:DropDownList>

2.在服務端處理的時候,尤其是初始化DropDownList的時候,沒注意結果寫錯了,下面是錯誤代碼:
復制代碼 代碼如下:

protected void Page_Load(object sender, EventArgs e)
{

if (!Page.IsCallBack)
{
this.fillIntoNameList();
}
}

這個初始化判斷出錯了,每次傳到服務器的時候會初始化一次,這就導致每次獲取DropDownList的SelectIndex的時候只能是0

正確代碼,如下:
復制代碼 代碼如下:

protected void Page_Load(object sender, EventArgs e)
{

if (!Page.IsPostBack)
{
this.fillIntoNameList();
}
}

相關文章

最新評論