私は3つのドロップダウンを持っています。最初の ddl、2 番目の ddl からアイテムを選択すると、それぞれのアイテムで生成されます。2 番目の ddl を選択すると、3 番目の ddl がそれぞれのデータで生成されます。私の問題は、3 番目の ddl からアイテムを選択するときに、3 つのアイテム (1 ddl の選択アイテム、2 ddl の選択アイテム、3 ddl の選択アイテム) をグリッド ビューに表示する必要があることです。それを達成する方法は?aspx ページ:
<body>
<form id="form1" runat="server">
<asp:DropDownList ID="DDLCountry" runat="server" OnSelectedIndexChanged="DDLCountry_SelectedIndexChanged" AutoPostBack="true">
<asp:ListItem>--Select-- </asp:ListItem>
<asp:ListItem>India</asp:ListItem>
<asp:ListItem>Australia</asp:ListItem>
<asp:ListItem>Pakistan</asp:ListItem>
</asp:DropDownList>
<asp:DropDownList ID="DDLState" runat="server" OnSelectedIndexChanged="DDLState_SelectedIndexChanged" AutoPostBack="true"></asp:DropDownList>
<asp:DropDownList ID="DDLCity" runat="server" AutoPostBack="true"></asp:DropDownList>
<div>
<asp:GridView ID="Grd1" runat="server">
</asp:GridView>
</div>
</form>
aspx.cs ページ
protected void DDLCountry_SelectedIndexChanged(object sender, EventArgs e)
{
DDLCity.Items.Clear();
DDLState.Items.Clear();
if (DDLCountry.SelectedIndex == 1)
{
DDLState.Items.Add(new ListItem("select", "0"));
DDLState.Items.Add(new ListItem("Kerala", "1"));
DDLState.Items.Add(new ListItem("AP", "2"));
DDLState.Items.Add(new ListItem("Karnataka", "3"));
}
else if (DDLCountry.SelectedIndex == 2)
{
DDLState.Items.Add(new ListItem("select", "0"));
DDLState.Items.Add(new ListItem("Victoria", "1"));
DDLState.Items.Add(new ListItem("Western Australia", "2"));
DDLState.Items.Add(new ListItem("New South Wales", "3"));
}
else if (DDLCountry.SelectedIndex == 3)
{
DDLState.Items.Add(new ListItem("select", "0"));
DDLState.Items.Add(new ListItem("Balochstan", "1"));
DDLState.Items.Add(new ListItem("Sindh", "2"));
DDLState.Items.Add(new ListItem("Punjab", "3"));
}
}
protected void DDLState_SelectedIndexChanged(object sender, EventArgs e)
{
DDLCity.Items.Clear();
if ((DDLCountry.SelectedIndex == 1) && (DDLState.SelectedIndex == 1))
{
DDLCity.Items.Add(new ListItem("Calicut", "0"));
DDLCity.Items.Add(new ListItem("Kochi", "1"));
}
else if ((DDLCountry.SelectedIndex == 1) && (DDLState.SelectedIndex == 2))
{
DDLCity.Items.Add(new ListItem("Hyderabad", "0"));
DDLCity.Items.Add(new ListItem("Vijayawada", "1"));
}
else if ((DDLCountry.SelectedIndex == 1) && (DDLState.SelectedIndex == 3))
{
DDLCity.Items.Add(new ListItem("Bengaluru", "0"));
DDLCity.Items.Add(new ListItem("Mysore", "1"));
}
else if ((DDLCountry.SelectedIndex == 2) && (DDLState.SelectedIndex == 1))
{
DDLCity.Items.Add(new ListItem("Melbourne", "0"));
DDLCity.Items.Add(new ListItem("A", "1"));
}
else if ((DDLCountry.SelectedIndex == 2) && (DDLState.SelectedIndex == 2))
{
DDLCity.Items.Add(new ListItem("Perth", "0"));
DDLCity.Items.Add(new ListItem("B", "1"));
}
else if ((DDLCountry.SelectedIndex == 2) && (DDLState.SelectedIndex == 3))
{
DDLCity.Items.Add(new ListItem("Sydney", "0"));
DDLCity.Items.Add(new ListItem("C", "1"));
}
else if ((DDLCountry.SelectedIndex == 3) && (DDLState.SelectedIndex == 1))
{
DDLCity.Items.Add(new ListItem("Lahor", "0"));
DDLCity.Items.Add(new ListItem("D", "1"));
}
else if ((DDLCountry.SelectedIndex == 3) && (DDLState.SelectedIndex == 2))
{
DDLCity.Items.Add(new ListItem("Karachi", "0"));
DDLCity.Items.Add(new ListItem("E", "1"));
}
else if ((DDLCountry.SelectedIndex == 3) && (DDLState.SelectedIndex == 3))
{
DDLCity.Items.Add(new ListItem("Peshawar", "0"));
DDLCity.Items.Add(new ListItem("F", "1"));
}
}