2013-01-02 72 views
2

我有4個下拉列表。當我更改第一個下拉列表時,onselectindexchangedchanged我需要更改所有剩餘的下拉值。 我正在處理它,但我只能更改onselectindexchanged的相應或下一個下拉值。請給我提供任何示例或指導我獲得任何良好的鏈接。 請幫助..在此先感謝。多個下拉列表

+0

什麼剩餘價值下拉菜單需要改變嗎? –

+0

請向我們展示您的相關代碼。這將有助於指出問題。 – Cdeez

+0

它需要更改爲默認值。 – user1613212

回答

3

您需要將所有下拉菜單的AutoPostBack設置爲true,並且需要爲前三個下拉菜單添加SelectedIndexChanged事件。在第一個下拉列表的SelectedIndexChanged中,您需要設置第二個選定值,它將觸發第二個SelectedIndexChanged,並且您將有代碼設置第三個選定索引,並且類似地,您將在病房中完成。

在HTML中

<asp:DropDownList ID="dropdownlist1" runat="server" AutoPostBack="true" OnSelectedIndexChanged="dropdownlist1_SelectedIndexChanged"> 
<asp:ListItem Value="1">1</asp:ListItem> 
<asp:ListItem Value="2">2</asp:ListItem> 
</asp:DropDownList> 

<asp:DropDownList ID="dropdownlist2" runat="server" AutoPostBack="true" OnSelectedIndexChanged="dropdownlist2_SelectedIndexChanged"> 
<asp:ListItem Value="1">1</asp:ListItem> 
<asp:ListItem Value="2">2</asp:ListItem> 
</asp:DropDownList> 

<asp:DropDownList ID="dropdownlist3" runat="server" AutoPostBack="true" OnSelectedIndexChanged="dropdownlist3_SelectedIndexChanged"> 
<asp:ListItem Value="1">1</asp:ListItem> 
<asp:ListItem Value="2">2</asp:ListItem> 
</asp:DropDownList> 

<asp:DropDownList ID="dropdownlist4" runat="server" AutoPostBack="true" > 
<asp:ListItem Value="1">1</asp:ListItem> 
<asp:ListItem Value="2">2</asp:ListItem> 
</asp:DropDownList> 

在後面的代碼

protected void dropdownlist1_SelectedIndexChanged(object sender, EventArgs e) 
{ 
     dropdownlist2.SelectedIndex = someIndexValue; 
} 

protected void dropdownlist2_SelectedIndexChanged(object sender, EventArgs e) 
{ 
     dropdownlist3.SelectedIndex = someIndexValue; 
} 

protected void dropdownlist3_SelectedIndexChanged(object sender, EventArgs e) 
{ 
     dropdownlist4.SelectedIndex = someIndexValue; 
} 
+1

謝謝阿迪爾..工作完美.. – user1613212

+0

不客氣。 – Adil

+2

如果它對你有幫助,你應該將它標記爲正確答案 –