【发布时间】:2020-02-18 03:49:01
【问题描述】:
我做了一个级联下拉列表。
这是第一个ddl:
<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack ="true" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged">
<asp:ListItem Text="-- Select One --"></asp:ListItem>
<asp:ListItem Text="Game"></asp:ListItem>
<asp:ListItem Text="Book"></asp:ListItem>
第二个 ddl 项目是根据 ddl1 (OnSelectedIndexChanged) 中选择的项目添加的
根据 ddl2 (OnSelectedIndexChanged) 中选择的项目添加第三个 dll 项目
我有一个问题,当我使用 DropDownList3.SelectedItem.Text 时,它总是返回第一个项目(基于每个选择的 CSGO 或 Dota),ddl1 和 ddl2 对我来说很好。
这里是 ddl2 函数:
protected void DropDownList2_SelectedIndexChanged(object sender, EventArgs e)
{
DropDownList3.Visible = true;
if (DropDownList2.SelectedValue == "A")
{
DropDownList3.Items.Clear();
DropDownList3.Items.Insert(0, new ListItem("-Select-", "N"));
DropDownList3.Items.Insert(1, new ListItem("CSGO", ""));
DropDownList3.Items.Insert(2, new ListItem("CSO", ""));
DropDownList3.Items[0].Attributes["disabled"] = "disabled";
}
else if (DropDownList2.SelectedValue == "B")
{
DropDownList3.Items.Clear();
DropDownList3.Items.Insert(0, new ListItem("-Select-", "N"));
DropDownList3.Items.Insert(1, new ListItem("Dota", ""));
DropDownList3.Items.Insert(2, new ListItem("LoL", ""));
【问题讨论】:
标签: c# asp.net drop-down-menu cascadingdropdown csharpcodeprovider