首先:模板列为用户自定义列,而绑定列是简单的数据绑定。所以这里我们选用模板列。

 

下面是绑定帖子状态,显示审核与未审核,而数据库中存的是0和1,所以要在程序中转化之后再绑定 

}

页面绑定(完成)

>

 

 

 勾选框模板列

>

选定所有

>

选择勾选框之后的处理(方法一:为微软提供的方法)

 sender, System.EventArgs e)
        {
            int intCount = this.Dg.Items.Count;
            
for(int i=0;i<intCount;i++)
            {
                CheckBox CheckSingle 
= this.Dg.Items[i].FindControl("CheckSingle"as CheckBox;
                
if(CheckSingle.Checked)
                {
                    
int suId = Convert.ToInt32(this.Dg.DataKeys[i].ToString());
                    dp.UpdateSubjectState(suId);
                }
            }
            DgBind();
        }
方法二:这样更简单,而且不用去记微软规定的方法
 sender, System.EventArgs e)
{
            int intCount = this.Dg.Items.Count;
            
for(int i=0;i<intCount;i++)
            {
         
//fy是页面上一个form内的一个元素 可以是文本框 也可以是下拉等,是元素的name
                string f = Request.Form["fy"];
            
string[] id = f.ToString().Split(',');
            
foreach(string i in id)
            {
                dp.UpdateState(
int.Parse(i));
            }
            DgBind();
 }
还有删除的绑定,篇幅太长了,下次再讲吧!dategrid添加勾选模板列方法2种

相关文章:

  • 2021-09-22
  • 2022-01-08
  • 2022-01-11
  • 2021-08-08
  • 2021-07-19
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-07-13
  • 2021-07-24
  • 2021-09-15
  • 2022-12-23
  • 2021-11-04
相关资源
相似解决方案