Function to get parent GridView for GridViewRow

A reference to the GridView can be obtained by using gridViewRow.Parent.Parent or (GridView) gridViewRow.NamingContainer(quote from here).

So I've created the static function:

        public static GridView GetParentGridView(GridViewRow row)
        {
            //NOTE row.Parent doesn't return GridView
            GridView gridView = (GridView)row.NamingContainer;
            return gridView;
        }
 

 

  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati
posted @ Sunday, February 24, 2008 3:56 PM
Print

Comments on this entry:

# re: Function to get parent GridView for GridViewRow

Left by Matthew Jones at 7/10/2009 7:55 AM
Gravatar
Thanks, this is exactly what I was looking for :-) You just saved me a bunch of hassle looking inside the debugger.

# re: Function to get parent GridView for GridViewRow

Left by Gaurav Soni at 12/14/2009 1:18 AM
Gravatar
Any idea how one can find the parent of a gridview pager row?

# re: Function to get parent GridView for GridViewRow

Left by Michael Freidgeim at 12/19/2009 7:25 PM
Gravatar
Put a bereakpoint in debugger where you are refer pager properties and check Parent, Parent.Parent, NamingContainer or something similar.

Your comment:



(not displayed)


 
 
 
 
 

Live Comment Preview:

 
«February»
SunMonTueWedThuFriSat
2930311234
567891011
12131415161718
19202122232425
26272829123
45678910