Geeks With Blogs

News My Blog has been MOVED to https://mfreidge.wordpress.com

Michael Freidgeim's OLD Blog My Blog has been MOVED to https://mfreidge.wordpress.com

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;
        }
 

 

Posted on Sunday, February 24, 2008 3:56 PM ASP.NET | Back to top


Comments on this post: Function to get parent GridView for GridViewRow

# re: Function to get parent GridView for GridViewRow
Requesting Gravatar...
Thanks, this is exactly what I was looking for :-) You just saved me a bunch of hassle looking inside the debugger.
Left by Matthew Jones on Jul 10, 2009 7:55 AM

# re: Function to get parent GridView for GridViewRow
Requesting Gravatar...
Any idea how one can find the parent of a gridview pager row?
Left by Gaurav Soni on Dec 14, 2009 1:18 AM

# re: Function to get parent GridView for GridViewRow
Requesting Gravatar...
Put a bereakpoint in debugger where you are refer pager properties and check Parent, Parent.Parent, NamingContainer or something similar.
Left by Michael Freidgeim on Dec 19, 2009 7:25 PM

# re: Function to get parent GridView for GridViewRow
Requesting Gravatar...
i want get the child row index..but when am going to use this code like
GridViewRow grow =(GridViewRow)(((TextBox)sender).Parent.Parent);
its fetching the parent row index property only..how can i get the child row index here
example..

if i have 5 rows in the parent table so 5th row index is 4 when am trying to go with 6 this is child row its again getting as row index 0 like 1 row..how can i get that as row index 5 for the 6 row
Left by Rahul on Apr 04, 2014 3:48 PM

# re: Function to get parent GridView for GridViewRow
Requesting Gravatar...
hfghfh
Left by nicrr on Jul 30, 2014 4:29 PM

Your comment:
 (will show your gravatar)


Copyright © Michael Freidgeim | Powered by: GeeksWithBlogs.net