?
Solved

How to create an event for a GridView CheckBox TemplateField

Posted on 2010-09-23
4
Medium Priority
?
484 Views
Last Modified: 2012-05-10
I have a number of TemplateFields created as CheckBoxes in a Gridview and need to create an event so that when any one of them is clicked it fires an event.
<asp:TemplateField HeaderText="SD" SortExpression="site_down">
                    <EditItemTemplate>
                        <asp:CheckBox ID="chkSD" runat="server" 
                            Checked='<%# Bind("site_down") %>' />
                    </EditItemTemplate>
                    <ItemTemplate>
                        <asp:CheckBox ID="chkSD" runat="server" Checked='<%# Bind("site_down") %>' 
                            Enabled="<%# true %>" />
                    </ItemTemplate>
                    
                </asp:TemplateField>

Open in new window

0
Comment
Question by:dcl120748
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 12

Accepted Solution

by:
Kaushal Arora earned 2000 total points
ID: 33742664
You can give a commandname to all of them in design time and then on the rowcommand event you can catch that particular command name and code for that only.

e.CommandName in the rowcommand name event will give you the commandname of the checkbox.

For help you can check this link:

http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.gridview.rowcommand.aspx

Hope it helps.
0
 

Author Comment

by:dcl120748
ID: 33742847
Thanks for that. I have given them command names and do use them for other purposes. Simply my problem is (and I am running short of time)  that when I click on one of these boxes I need it to fire an event that I can trap. For example when I click on the CheckBox where the ID is "chkSD" (as above) I want to trigger an event. I suspect there is also the issue of 'PostBack' here as well?
0
 

Author Comment

by:dcl120748
ID: 33912310
I have no objection but I am just surprised that for a second time in a row I have asked a question, then responded to a request for further information and then heard absolutely nothing. I am questioning the value of being a premium member.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question