Solved

How to create an event for a GridView CheckBox TemplateField

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

Enroll in May's Course of the Month

May’s Course of the Month is now available! Experts Exchange’s Premium Members and Team Accounts have access to a complimentary course each month as part of their membership—an extra way to increase training and boost professional development.

Question has a verified solution.

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

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

738 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