Tutorials
Resources
Forum
Reviews
Communities
Interview
Jobs
Projects
Training
Your
Ad
Here
Silverlight Games
|
Mentor
|
Code Converter
|
Articles
|
Code Factory
|
Computer Jokes
|
Members
|
Peer Appraisal
|
IT Companies
|
Bookmarks
|
Polls
|
Revenue Sharing
|
Lobby
|
Gift Shop
|
Prizes & Awards
My Profile
Sign In
Register
AdSense Revenue
Active Members
Today
Alwyn
(54)
srinivas kante...
(44)
Nadheera V
(40)
Last 7 Days
Alwyn
(718)
nishithraj
(512)
Gaurav Arora
(501)
more...
Resources
»
Code Snippets
»
DataGridView
»
Checkbox column checkall uncheckall in DataGrid C#
Posted Date: 23 Aug 2008
Resource Type:
Code Snippets
Category:
DataGridView
Author:
Tamanna
Member Level:
Silver
Rating:
Points
: 10
Following code will create a checkbox in HeaderTemplate and 1 checkbox in ItemTemplate.
<asp:DataGrid ID="DataGrid1" runat="server" AutoGenerateColumns="false" Width="100%" OnItemCommand="DataGrid1_ItemCommand1" OnSelectedIndexChanged="DataGrid1_SelectedIndexChanged1" Height="181px">
<Columns>
<asp:TemplateColumn>
<HeaderTemplate>
<input id="chkAll" type="checkbox" onclick="CheckAllDataGridCheckBoxes('chkItem',this)"/>
</HeaderTemplate>
<ItemTemplate>
<asp:CheckBox ID="chkItem" runat="server"></asp:CheckBox>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:DataGrid>
Following code is to be written under head tag.
<script type="text/javascript">
function CheckAllDataGridCheckBoxes(aspCheckBoxID,checkVal)
{
var len=document.getElementsByTagName("input").length;
for(i = 0; i < len; i++)
{
if (document.getElementsByTagName("input")[i].type == 'checkbox')
{
document.getElementsByTagName("input")[i].checked=checkVal.checked
}
}
}
</script>
Responses
No responses found. Be the first to respond and make money from
revenue sharing program
.
Feedbacks
Popular Tags
What are tags ?
Search Tags
Sign In
to add tags.
Uncheckall
.
In DataGrid C#
.
Checkbox column
.
Checkall
.
Post Feedback
This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must
Sign In
to post a response.
Next Resource:
Data in Grid view in Descending. Order
Previous Resource:
Open new Window using DataGrid C#
Return to Discussion Resource Index
Post New Resource
Category:
DataGridView
Post resources and
earn money
!
More Resources
Data in Grid view in Descending. Order
Command Name of Hyperlink in DataList C#
conversion of datagrid view to excel format
Paging and Sorting a GridView in XAML
Obtaining Checkbox's SelectedItem
Add Checkbox to ListView in WPF
dotNet Slackers
About Us
Contact Us
Privacy Policy
Terms Of Use