My question got answered on another forum:
By Ahmed Fouad
---------------------
As of my understanding, rebinding the parent repeater causes any nested
controls (including nested DataGrid) to reinstantiate. This is the reason
why the EditItemIndex property of the child grid resets to -1 (the default).
You need to store the EditItemIndex in a class level variable and then use
this variable in the ItemCreated event of the Repeater (parent) control.
Something like the following should do the trick:
' declare class level variables to preserve nested state
Private m_childGridIndex As Integer ' allows us to locate instance of
the child grid for which EditCommand was last fired
Private m_editItemIndex As Integer ' you already know whats this
for....
Protected Sub dgChild_EditCommand(. . .)
Dim myInnerDG As DataGrid = CType(source, DataGrid)
' no need to do that because it will be reset to -1 after invoking
RefreshData() method
'myInnerDG.EditItemIndex = e.Item.ItemIndex
' The following lines will rescue our precious indices to be used in
Repeater's ItemCreated event handler...
m_childGridIndex = CType(myInnerDG.NamingCont
RepeaterItem).ItemIndex
m_editItemIndex = e.Item.ItemIndex
RefreshData()
End Sub
Private Sub Repeater_ItemCreated(. . .)
If e.Item.ItemType = ListItemType.Item OrElse e.Item.ItemType =
ListItemType.AlternatingIt
If e.Item.ItemIndex = m_childGridIndex Then
Dim dgChild As DataGrid =
DirectCast(e.Item.FindCont
dgChild.EditItemIndex = m_editItemIndex
End If
End If
End Sub
Main Topics
Browse All Topics





by: valkyrie_ncPosted on 2005-12-20 at 14:22:27ID: 15522396
When I've done things like this in the past, I had to create separate binding functions for the repeater and the datagrids, and call them in appropriate places: both in the initial BindData function, repeater databind function in repeater command functions, and datagrid databind function in datagrid command functions.
hth
valkyrie_nc