//绑定GridView每一行中的CheckBoxList
    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            CheckBoxList cbl = (CheckBoxList)e.Row.FindControl("ckbCheckBox");
            if (cbl != null)
            {
                BindCheckBoxList(cbl);
            }
        }
    }
    //绑定CheckBoxList的方法
    private void BindCheckBoxList(CheckBoxList cbl)
    {
        string strSQL = "Select login_id,login_name from 表名 where 条件";
        DataTable dt = GetData(strSQL);//这里的方法根据你自己的取数据的方法
        cbl.DataSource = dt;
        cbl.DataValueField = "login_id";
        cbl.DataTextField = "login_name";
        cbl.DataBind();
    }

 

相关文章:

  • 2022-01-04
  • 2021-08-19
  • 2022-12-23
  • 2021-06-21
  • 2021-11-26
猜你喜欢
  • 2021-09-15
  • 2021-11-09
  • 2022-12-23
  • 2021-06-19
  • 2021-10-09
  • 2022-12-23
  • 2020-06-20
相关资源
相似解决方案