Pages

Thursday, January 26, 2012

Get the GridView control from the TextBox insides the GridView

1.You have one or more than one GridView(s) on your page.
2.Each GridView has one or more TextBox(s) in it.
3.At the TextChanged() event, you want to/have to know which GridView owns the event.
Here is the way to get the parent control of that TextBox:
1
2
3
//get the parent gridview
GridViewRow gvr = (GridViewRow)(((TextBox)sender).Parent).Parent;
GridView gv = (GridView)(gvr.Parent).Parent;

Once you get the GridViewRow, you can get the RowIndex value. Once you get the GridView, you get everything...


enj.........................

No comments:

Post a Comment