Check/Uncheck All Checkboxes in Asp.Net Gridview
来源:互联网 发布:网络物流信息平台 编辑:程序博客网 时间:2024/06/06 07:50
Introduction:
In this article we will see how to check and uncheck all CheckBoxes present in an ASP.Net GridView control.
Background:
While programming many times we need to use a CheckBox control in an ASP.Net GridView for allowing selection of a particular row of a GridView. In some cases a GridView can contain 100 of records and if the user wants to select all rows of the GridView then selecting each row one by one is very tedious and a time-consuming job. To make it easier we will see how to write a simple method for selecting all CheckBoxes in a GridView. Take a look at the following snippets.
Conclusion:
By using a simple method we are able to check/uncheck 100 of rows also in GridView.
In this article we will see how to check and uncheck all CheckBoxes present in an ASP.Net GridView control.
Background:
While programming many times we need to use a CheckBox control in an ASP.Net GridView for allowing selection of a particular row of a GridView. In some cases a GridView can contain 100 of records and if the user wants to select all rows of the GridView then selecting each row one by one is very tedious and a time-consuming job. To make it easier we will see how to write a simple method for selecting all CheckBoxes in a GridView. Take a look at the following snippets.
- Create a new website. On the default.aspx page keep the GridView control with AutogeneratedColumn = false. The source for the GridView should look like below.
asp:GridViewID="GridView1" runat="server" AutoGenerateColumns="False">
<Columns>
<asp:TemplateFieldShowHeader="false">
<ItemTemplate>
<asp:CheckBoxID="chkid" runat="server" />
</ItemTemplate>
</asp:TemplateField>
<asp:BoundFieldDataField="Auth_Name"HeaderText="Author Name"/>
<asp:BoundFieldDataField="Auth_Loc"HeaderText="Location"/>
</Columns>
</asp:GridView> - Keep two buttons on the form; one for checking all checkboxes and the other for unchecking.
- The CheckState method is for performing a check/uncheck operation in the GridView. This method will take true/false as input to check/uncheck the checkboxes of the GridView.
privatevoid CheckState(bool p)
{foreach (GridViewRow row in GridView1.Rows)
{
CheckBox chkcheck = (CheckBox)row.FindControl("chkid");
chkcheck.Checked = p;
}
} - Bind your GridView and run.
Conclusion:
By using a simple method we are able to check/uncheck 100 of rows also in GridView.
- Check/Uncheck All Checkboxes in Asp.Net Gridview
- Check/Uncheck checkboxes in GridView using JavaScript
- ASP.NET 2.0 Treeview Checkboxes - Check All - Javascript
- ASP.NET 2.0 Treeview Checkboxes - Check All - Javascript
- .Net Treeview Checkboxes - Check All 功能
- Check/Un-Check checkboxes items in ASP.NET DataGrid using JavaScript
- Checkboxes Beside Labels in ASP.Net MVC4
- Scott Mitchell 的ASP.NET 2.0数据教程之52:为GridView控件添加Checkboxes列
- Collapsible GridView in ASP.Net 2.0
- Export GridView To WordExcelPDFCSV in ASP.Net
- check exception和uncheck exception
- check exception和uncheck exception
- check exception和uncheck exception
- C#中check和uncheck
- C#中check和uncheck
- Check Exception or Uncheck Exception
- 例子——dhtmlxTree之checkboxes(ASP.NET)
- Select Single Radio Button in Gridview in Asp.Net
- linux 备份系统方法
- Java拼接多张图片,可以连接在一起
- paradox数据库的创建与数据操作
- java 内部类
- Tcode
- Check/Uncheck All Checkboxes in Asp.Net Gridview
- asp:FileUpload 上传文件
- volatile 和 sig_atomic_t
- android在一个应用中启中另外一个应用
- Myeclipse9 JQuery加载时invalid FormalParameter
- Session过期时间问题
- for循环时jquery闭包问题
- String中intern的方法
- 作业调用包含FTP组件的SSIS包