62,270
社区成员
发帖
与我相关
我的任务
分享
if (!Page.IsPostBack)
{
string sqlconstr = ConfigurationManager.ConnectionStrings["ConnectionServer"].ConnectionString;
SqlConnection con = new SqlConnection(sqlconstr);
con.Open();
SqlCommand cmd = new SqlCommand("select * from [WORK]", con);
SqlDataReader sdr = cmd.ExecuteReader();
this.DropDownList1.Items.Add("未选择");
this.DropDownList1.DataSource = sdr;
this.DropDownList1.DataTextField = "name";
this.DropDownList1.DataValueField = "mode";
this.DropDownList1.DataBind();
sdr.Close();
con.Close();
}
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
string sqlconstr = ConfigurationManager.ConnectionStrings["ConnectionServer"].ConnectionString;
SqlConnection con = new SqlConnection(sqlconstr);
con.Open();
SqlCommand cmd = new SqlCommand("select * from [group] where mode=" + this.DropDownList1.SelectedValue + "", con);
SqlDataReader sdr = cmd.ExecuteReader();
this.DropDownList2.DataSource = sdr;
this.DropDownList2.DataTextField = "groupname";
this.DropDownList2.DataValueField = "grouptype";
this.DropDownList2.DataBind();
sdr.Close();
con.Close();
}


抽根烟,帮顶