我想在带有复选框的网格视图中显示记录 [英] I want to show the record in grid view with chek box option

查看:84
本文介绍了我想在带有复选框的网格视图中显示记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在网格视图中显示记录,并且我具有字段调用状态,当用户检查复选框时状态将显示为活动",而当用户取消选中复选框时状态将显示为不活动"? ="h2_lin">解决方案

在yopur网格视图中的列标记下添加模板字段.

 <   asp:TemplateField     HeaderText   =" 有效/无效"  > 
                           <   EditItemTemplate  > 
                               <   asp:CheckBox     ID   ="   runat   服务器" / <  /EditItemTemplate  > 
                           <   ItemTemplate  > 
                               <   asp:CheckBox     ID   ="   runat   服务器" / <  /ItemTemplate  > 
                       <  /asp:TemplateField  >  



//-------复选框代码单击

  for ( int  i =  0 ;我<   int  .Parse(RegView.Rows.Count.ToString( )); i ++)
{
CheckBox myCheckBox =(CheckBox)RegView.Rows [i] .FindControl(" );
                    如果(myCheckBox.Checked == )
                    {
                      // 做活动
                    }
} 


有关更多详细信息,请访问

http://www.ilearnttoday.com/tag/adding-a-template-column- to-gridview [ ^ ]


请参阅这些
http://www.ezzylearning.com/tutorial.aspx?tid=5187857 [ ^ ]
Selecting-multiple-checkboxes-inside-a-GridView-co [^ ]
http://www.asp.net/web-forms/tutorials/data-access/enhancing-the-gridview/adding-a-gridview-column-of-checkboxes-cs [ 解决方案

Add Template Field in yopur grid view under columns tag.

<asp:TemplateField HeaderText="Active/Inactive">
                           <EditItemTemplate>
                               <asp:CheckBox ID="CheckBox1" runat="server" />
                           </EditItemTemplate>
                           <ItemTemplate>
                               <asp:CheckBox ID="CheckBox1" runat="server" />
                           </ItemTemplate>
                       </asp:TemplateField>



//------- code for check box click

for (int i = 0; i < int.Parse(RegView.Rows.Count.ToString()); i++)
{
CheckBox myCheckBox = (CheckBox)RegView.Rows[i].FindControl("CheckBox1");
                    if (myCheckBox.Checked == true)
                    {
                      // do the activity
                    }
}


For more details visit

http://www.ilearnttoday.com/tag/adding-a-template-column-to-gridview[^]


Refer these
http://www.ezzylearning.com/tutorial.aspx?tid=5187857[^]
Selecting-multiple-checkboxes-inside-a-GridView-co[^]
http://www.asp.net/web-forms/tutorials/data-access/enhancing-the-gridview/adding-a-gridview-column-of-checkboxes-cs[^]


这篇关于我想在带有复选框的网格视图中显示记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
其他开发语言最新文章
热门教程
热门工具
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆