Click here to Skip to main content
12,956,512 members (80,308 online)
Click here to Skip to main content
Add your own
alternative version

Stats

16.2K views
15 bookmarked
Posted 24 Aug 2007

DataGrid Control fill CheckBox on Client Side

, 24 Aug 2007
Rate this:
Please Sign up or sign in to vote.
This Concept is used to, just click on header checkbox then the all checkbox are checked with out postback operation by using javascript. For example in yahoo mail u just click the header checkbox all grid checkbox will be selected

// This is the javascript code. Just copy and paste the code within the script tag

function CheckAllDataGridCheckBoxes(aspCheckBoxID, checkVal)

{

re = new RegExp(':' + aspCheckBoxID + '$')

for(i = 0; i < Form1.elements.length; i++)

{

elm = document.forms[0].elements[i] if (elm.type == 'checkbox')

{

if (re.test(elm.name)) elm.checked = checkVal

}

}

}

// This is the sample design structure of the datagrid, in only display the checkbox and name

<templatecolumn headertext="Select All"></headertemplate /><itemtemplate />

< />
<checkbox id="chkItem" runat="server" />

<imagebutton id="btnDownload" commandname="cmdDownload" runat="server" imageurl="/jobants/images/download.gif"><asp:datagrid id="dgReciveApp" runat="server" AutoGenerateColumns="False" Width="100%" PageSize="15"
AllowPaging="True" DataKeyField="vc_UserName">
<Columns>
<asp:TemplateColumn HeaderText="Select All">
<HeaderTemplate>
<input ID="chkAll" type="checkbox" onclick="CheckAllDataGridCheckBoxes('chkItem',this.checked)">
Select All</HeaderTemplate>
<ItemTemplate>
<TABLE WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0">
<TR>
<TD WIDTH="3%" BGCOLOR="#FFFFFF" height="100%">
<table width="100%" height="100%">
<tr valign="top" height="100%">
<td>
<asp:CheckBox ID="chkItem" Runat="server"></asp:CheckBox></td>
<tr valign="middle" height="100%">
<td valign="middle">

<imagebutton commandname="cmdDownload" runat="server" imageurl="/jobants/images/download.gif"> <%# DataBinde.Eval(Container.DataItem,"Name") %>
</td>
</tr>
</table>
</TD>

<imagebutton commandname="cmdDownload" runat="server" imageurl="/jobants/images/download.gif"></tr>

<imagebutton commandname="cmdDownload" runat="server" imageurl="/jobants/images/download.gif"></table></table /> </table /> </table>
</ItemTemplate> </asp:TemplateColumn> </Columns></asp:datagrid>

<imagebutton commandname="cmdDownload" runat="server" imageurl="/jobants/images/download.gif" />

<imagebutton commandname="cmdDownload" runat="server" imageurl="/jobants/images/download.gif" />

<imagebutton commandname="cmdDownload" runat="server" imageurl="/jobants/images/download.gif" />

<imagebutton commandname="cmdDownload" runat="server" imageurl="/jobants/images/download.gif" />

<imagebutton commandname="cmdDownload" runat="server" imageurl="/jobants/images/download.gif">Here if u click the header checkbox all datagrid itemtemplate ceckbox are selected </itemtemplate /></columns /></itemtemplate /></columns />

<script language="javascript"></script>

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

Share

About the Author

vijimvv1
Web Developer
India India
fun

You may also be interested in...

Pro

Comments and Discussions

 
JokeWow GREAT ARTICLE!!!!! (NOT) Pin
ednrgc28-Aug-07 8:57
memberednrgc28-Aug-07 8:57 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.170525.1 | Last Updated 25 Aug 2007
Article Copyright 2007 by vijimvv1
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid