Solved

How to create an event for a GridView CheckBox TemplateField

Posted on 2010-09-23
4
457 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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

758 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

19 Experts available now in Live!

Get 1:1 Help Now