i want to use cascading dropdownlist its like this i have one dropdown \ Hardware software Network when i click network its should only display dropdown list of network problems same for software and Hardware i am trying like this Aspx <pre lang="HTML"> <asp:DropDownList ID="PRB_type_ddl" runat="server" DataTextField="prob_type" DataValueField="prob_type" Height="20px" Width="114px" onselectedindexchanged="DropDownList3_SelectedIndexChanged1" AutoPostBack="True" > <asp:ListItem>--Select--</asp:ListItem> <asp:ListItem>Hardware</asp:ListItem> <asp:ListItem>Software</asp:ListItem> <asp:ListItem>Network</asp:ListItem> </asp:DropDownList> <br /> </td> <td class="style33"> <span class="style28"> <asp:DropDownList ID="Hard_ddl" runat="server" DataTextField="Hardware" DataValueField="Hardware" DataSourceID="SqlDataSource3"> </asp:DropDownList> <asp:SqlDataSource ID="SqlDataSource3" runat="server" ConnectionString="<%$ ConnectionStrings:con %>" SelectCommand="SELECT [Hardware] FROM [p_type]"></asp:SqlDataSource> <asp:DropDownList ID="Soft_ddl" runat="server" DataTextField="Software" DataValueField="Software" DataSourceID="SqlDataSource5"> </asp:DropDownList> <asp:SqlDataSource ID="SqlDataSource5" runat="server" ConnectionString="<%$ ConnectionStrings:con %>" SelectCommand="SELECT [Software] FROM [p_type]"></asp:SqlDataSource> <asp:DropDownList ID="OP_ddl" runat="server" DataTextField="Operating_system" DataValueField="Operating_system" DataSourceID="SqlDataSource6"> </asp:DropDownList> <asp:SqlDataSource ID="SqlDataSource7" runat="server" ConnectionString="<%$ ConnectionStrings:con %>" SelectCommand="SELECT [Net_work] FROM [p_type]"></asp:SqlDataSource> c#
protected void DropDownList3_SelectedIndexChanged1(object sender, EventArgs e) { if (PRB_type_ddl.SelectedValue == "Hardware") { Hard_ddl.Visible = true; Soft_ddl.Visible = false; NET_ddl.Visible = false; Soft_ddl.SelectedIndex = -1; NET_ddl.SelectedIndex = -1; } else if (PRB_type_ddl.SelectedValue == "Software") { Soft_ddl.Visible = true; NET_ddl.Visible = false; Hard_ddl.Visible = false; Hard_ddl.SelectedIndex = -1; NET_ddl.SelectedIndex = -1; } else { NET_ddl.Visible = true; Hard_ddl.Visible = false; Soft_ddl.Visible = false; Soft_ddl.SelectedIndex = -1; Hard_ddl.SelectedIndex = -1; } } con.Open(); SqlCommand cmd = new SqlCommand(); cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = "Tech_sup"; cmd.Parameters.AddWithValue("@Build_name", Build.Text); cmd.Parameters.AddWithValue("@Dept", DropDownList2.Text); if (string.IsNullOrEmpty(Hard_ddl.Text)) { cmd.Parameters.Add(new SqlParameter("@P_type", DBNull.Value.ToString())); } else { cmd.Parameters.Add(new SqlParameter("@P_type", Hard_ddl.Text)); } if (string.IsNullOrEmpty(Soft_ddl.Text)) { cmd.Parameters.Add(new SqlParameter("@P_type", DBNull.Value.ToString())); } else { cmd.Parameters.Add(new SqlParameter("@P_type", Soft_ddl.Text)); } if (string.IsNullOrEmpty(NET_ddl.Text)) { cmd.Parameters.Add(new SqlParameter("@P_type", DBNull.Value.ToString())); } else { cmd.Parameters.Add(new SqlParameter("@P_type", NET_ddl.Text)); } cmd.Connection = con; cmd.ExecuteNonQuery(); con.Close();
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)