Solved

How to Get Column Index of a Row in GridView When a Footer Cell CheckBox Is Clicked

Posted on 2014-03-07
5
1,912 Views
Last Modified: 2014-03-15
I have a GridView dynamically bind with database table.  I use TemplateField to create a CheckBox in each column's footer.  I added EventHandler when CheckedChanged for each CheckBox.  When user clicks CheckBox, I want to change color of entire column.   How do I get cell index when a CheckBox is clicked by user in CheckedChanged EvenHandler?
0
Comment
Question by:khrispy
  • 3
  • 2
5 Comments
 
LVL 16

Expert Comment

by:SriVaddadi
ID: 39914694
Type cast sender to CheckBox and access the Parent property and that would give you the cell. You can go from there.

GridViewRow Row = ((GridViewRow)((Control)sender).Parent.Parent);

GridViewColumn Col = (GridViewColumn)((Control)sender.Parent)
0
 

Author Comment

by:khrispy
ID: 39918874
GridViewColumn is Windows control.  I am using ASP .NET and I can't cast sender to GridViewColumn.  This is what I got stuck.
0
 

Accepted Solution

by:
khrispy earned 0 total points
ID: 39919343
I ended up get clicked CheckBox control and compare with each cell's CheckBox to get column number.
0
 
LVL 16

Expert Comment

by:SriVaddadi
ID: 39919423
oh ok.. but u could still use GridViewRow and get the Cells and it is of Type TableCell
0
 

Author Closing Comment

by:khrispy
ID: 39931100
I found the solution myself.
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
Error when loading the database 16 57
Run time Error 4 34
Connection String 16 43
C#  Radio button search for Date not DateTime 4 35
Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
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!
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…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

867 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

16 Experts available now in Live!

Get 1:1 Help Now