How to refer to parent DataGrid from DataGridItem - use NamingContainer

It's published in a few places, but I had to do a few Google searches before confirming that you should use NamingContainer property to get parent DataGrid for DataGridItem. So I've created a shared method in my WebFormsHelper class.

    Public Shared Function ParentDataGrid(ByVal Item As DataGridItem) As DataGrid

        ' Dim gridTable As DataGridTable = Item.Parent 'DataGrid = gridTable.Parent doesn't work because  MS declared DataGridTable as private(why?)

        Dim grid As DataGrid = Item.NamingContainer

        Return grid

    End Function

posted @ Tuesday, July 18, 2006 8:47 AM

Print

Comments on this entry:

No comments posted yet.

Your comment:



 (will not be displayed)


 
 
 
 
 

Live Comment Preview:

 
«November»
SunMonTueWedThuFriSat
25262728293031
1234567
891011121314
15161718192021
22232425262728
293012345