Tutorials
Resources
Forum
Communities
Interview
Jobs
Projects
Offshore Development
Silverlight Tutorials
|
Mentor
|
Code Converter
|
Articles
|
Code Factory
|
Computer Jokes
|
Members
|
Peer Appraisal
|
IT Companies
|
Bookmarks
|
Revenue Sharing
|
Prizes & Awards
My Profile
Sign In
Register
AdSense Revenue
Active Members
Today
Abhi
(77)
Appukuttan
(40)
raj krishna
(37)
Last 7 Days
Appukuttan
(660)
Babu Akkandi
(467)
Tejinder Singh ...
(278)
more...
New Feature:
Community Sites
:
Create your own .NET community website and start earning from Google AdSense !
It's Free !
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
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
!
Related Resources
Displaying Records from 5 to 15 in GridView
Merge columns in a DataGridView as in Excel SpreadSheet
How to Edit,Delete,Update in Datagrid in vs2008?
Databinding the GRID VIEW using C#
Export Datagrid Data To Excel
dotNet Slackers
BizTalk Adaptors
Web Design
Contact Us
Privacy Policy
Terms Of Use