级联下拉列表与重新加载页面

时间:2016-10-10 06:29:37

标签: sql-server-2008

如何在选择第一个下拉列表时级联第二个下拉列表而不重新加载页面 下拉列表中没有自动回复

<asp:DropDownList ID="dropcaste" Width="128px" runat=server AutoPostBack=true
                                onselectedindexchanged="dropcaste_SelectedIndexChanged"></asp:DropDownList>


 protected void dropcaste_SelectedIndexChanged(object sender, EventArgs e)
    {
        string select = dropcaste.SelectedItem.Value;
        con = new SqlConnection(str);
        cmd = new SqlCommand("select c.castename,s.subcastename from subcastemaster_mrg s inner join castemas_mrg c on(s.castecode=c.castecode) where c.castecode=" + select + "", con);
        con.Open();
        SqlDataAdapter sda = new SqlDataAdapter();
        sda.SelectCommand = cmd;
        DataTable dt = new DataTable();
        sda.Fill(dt);
        subcastegrid.DataSource = dt;
        subcastegrid.DataBind();
        con.Close();
    }

0 个答案:

没有答案