Hi, I am having a problem when trying to edit a parent table that has two details on the same level when I have the
HierarchyDefaultExpanded="True" . Everything works as expected when that is false. The problem is when I am going into editmode for the parent grid ("USERINFO") the detail tables are still trying to be drawn but in the case statment for USERPHONE the drv is pulling the row for the parent row and the column does not exist in the parent. I was expecting that the e.item.dataitem would be the detail rows. Any help would be appreciated. The parts in bold below are where I think the problem is occurring.
Protected
Sub radgridUser_ItemDataBound(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridItemEventArgs) Handles radgridUser.ItemDataBound
Dim lbl As Label
Select Case e.Item.OwnerTableView.Name.ToUpper
Case "USERINFO"
If (TypeOf e.Item Is GridDataItem AndAlso Not e.Item.IsInEditMode) Then
Dim drv As DataRowView = CType(e.Item.DataItem, DataRowView)
lbl =
DirectCast(e.Item.FindControl("lblName"), Label)
lbl.Text = drv(
"FirstName") & IIf(drv("MiddleName") = " ", " ", " " & drv("MiddleName") & " ") & drv("LastName")
End If
Case "USERPHONE"
'not in edit mode
If (TypeOf e.Item Is GridDataItem AndAlso Not e.Item.IsInEditMode) Then
Dim drv As DataRowView = CType(e.Item.DataItem, DataRowView)
lbl =
DirectCast(e.Item.FindControl("lblPhoneType"), Label)
lbl.Text = drv(
"PhoneTypeDesc") <--- Blows up here because "phonetypedesc" does not belong to userinfo table
End If
If (TypeOf e.Item Is GridEditableItem AndAlso e.Item.IsInEditMode AndAlso Not TypeOf e.Item Is GridEditFormInsertItem) Then
Dim item As GridEditableItem = e.Item
Dim drv As DataRowView = CType(e.Item.DataItem, DataRowView)
'access/modify the edit item template settings here
Dim list As DropDownList = item.FindControl("ddlPhoneType")
list.DataSource = dvPhoneTypes
list.DataTextField =
"PhoneTypeDesc"
list.DataValueField =
"PhoneTypeId"
list.DataBind()
list.SelectedValue = (drv(
"PhoneTypeId")).ToString
End If
Case "USERADDRESS"
End Select
End Sub