Dropdownlist控件的事件处理

protected void bindhbdata(string chatid)
{
    string sql = "select * from staff where wechatid='"+ chatid +"'";
    SqlDataReader dr = SqlHelper.ExecuteReader(SqlHelper.mycon, CommandType.Text, sql);
    if(dr.Read())
    {
        this.unit.Text = dr["unit"].ToString();
        this.hcagent.Text = dr["staffname"].ToString();
        this.hcagent_tl.Text = dr["tl"].ToString();
        string sqltl = "select * from staff where unit='"+ dr["unit"].ToString () +"' and rank in ('tl')";
        DataSet ds = SqlHelper.ExecuteDataset(SqlHelper.mycon, CommandType.Text, sqltl);
        //DataRow NewRow = ds.Tables[0].NewRow();
        //ds.Tables[0].Rows.Add(NewRow);
        this.t_tl.DataSource = ds.Tables[0].DefaultView;
        this.t_tl.DataTextField = "staffname";
        t_tl.DataBind();
        t_tl.Items.Insert(0, new ListItem("请选择", "0"));

    }
    dr.Close();

}
protected void t_tl_SelectedIndexChanged(object sender, EventArgs e)
{
    string tlname= t_tl.SelectedValue;
    string t_agent = "select * from staff where tl='"+ tlname +"'";
    DataSet ds = SqlHelper.ExecuteDataset(SqlHelper.mycon, CommandType.Text, t_agent);
    t_hragent.DataSource = ds.Tables[0].DefaultView;
    t_hragent.DataTextField = "staffname";
    t_hragent.DataBind();

}

posted @ 2015-05-03 12:58  皮皮木有小JJ  阅读(273)  评论(0编辑  收藏  举报