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,873 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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
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…

743 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

10 Experts available now in Live!

Get 1:1 Help Now