Solved

How to create an event for a GridView CheckBox TemplateField

Posted on 2010-09-23
4
459 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
  • 2
4 Comments
 
LVL 12

Accepted Solution

by:
Kaushal Arora earned 500 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to get the web content with different encodings 2 30
Error in query expression 3 37
C# Json POSt to Rest API 4 38
how to read json value 2 32
A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

863 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

Need Help in Real-Time?

Connect with top rated Experts

25 Experts available now in Live!

Get 1:1 Help Now