protected void SelectDeptment(object sender, EventArgs e) { string strdeptname = deptment.SelectedItem.Value; string strsql = "select * from AccountInf where Deptment='" + strdeptname + "' and Authority='客服'"; DbHelp dbmanage = new DbHelp(EnumDbType.DbSqlServer, "server=NOLAN-DEBUG-PC\\SQLEXPRESS1;database=test;Trusted_Connection=SSPI;"); DataSet ds = dbmanage.QueryToDs(strsql); DropDownListstaf.DataSource = ds.Tables[0].DefaultView; DropDownListstaf.DataTextField = "UserName"; DropDownListstaf.DataValueField = "ID"; DropDownListstaf.DataBind(); }
void bindstaff(string sql) { DbHelp dbmanage = new DbHelp(EnumDbType.DbSqlServer, "server=NOLAN-DEBUG-PC\\SQLEXPRESS1;database=test;Trusted_Connection=SSPI;"); DataSet ds = dbmanage.QueryToDs(sql); DropDownListstaf.DataSource = ds.Tables[0].DefaultView; DropDownListstaf.DataTextField = "UserName"; DropDownListstaf.DataValueField = "ID"; DropDownListstaf.DataBind(); ListItem ltselext = new ListItem(); ltselext.Text = "全部人员"; ltselext.Value = "全部人员"; DropDownListstaf.Items.Insert(0, ltselext); }