[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2171
  • Last Modified:

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

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
khrispy
Asked:
khrispy
  • 3
  • 2
1 Solution
 
SriVaddadiCommented:
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
 
khrispyAuthor Commented:
GridViewColumn is Windows control.  I am using ASP .NET and I can't cast sender to GridViewColumn.  This is what I got stuck.
0
 
khrispyAuthor Commented:
I ended up get clicked CheckBox control and compare with each cell's CheckBox to get column number.
0
 
SriVaddadiCommented:
oh ok.. but u could still use GridViewRow and get the Cells and it is of Type TableCell
0
 
khrispyAuthor Commented:
I found the solution myself.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now