all groups > asp.net datagrid control > december 2005 >
You're in the

asp.net datagrid control

group:

How does a nested datagrid reference parent row in master datagrid?


Re: How does a nested datagrid reference parent row in master datagrid? Elton Wang
12/20/2005 1:45:28 PM
asp.net datagrid control:
You can try

child.NamingContainer and cast it to a datagridrow


HTH


[quoted text, click to view]

How does a nested datagrid reference parent row in master datagrid? nospam NO[at]SPAM nospam.sss
12/20/2005 5:38:22 PM
I have a nested datagrid in each row of a master datagrid. The nested grid
has full functionality of inline edits. How do I reference the datakey
collection of the master datagrid passing the proper collection index?

For example, if someone clicks 'edit' or 'update' link in the child
datagrid of the second row of the master datagrid, I need to be able to
reference the DataKeys collection of the master datagrid passing the index
of 1 which is the second row... all this from the updatecommand event
handler of the child datagrid.

Re: How does a nested datagrid reference parent row in master datagrid? Rocky Road
1/19/2006 1:54:18 PM
I had a good break throught with your tip. I was able to get to the
Parent datalist control as show below. But now I need the index value of
the parent control's (a datalist) Item where the child control resides
so that I can used it to access the Item's DataKey value.

dlsChild = CType(source, DataList)
c = dlsChild .NamingContainer ' This gives me Nothing,
but let's me move 1 level up
dlsParent = CType(c.NamingContainer, DataList) ' But
calling it one more time gives me the Parent
Dim i As Integer = dlsParent.Items(dlsChild
.MyParentItemsIndex).ItemIndex ' I need the Index of the parent Item
myDataKeyInt= dlsParent.DataKeys(i).ToString

Obvisous Obs: dlsChild .MyParentItemsIndex is a fake property

AddThis Social Bookmark Button