This is a migrated thread and some comments may be shown as answers.

Editing parent when details are expanded.

1 Answer 103 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Henry Derstine
Top achievements
Rank 1
Henry Derstine asked on 10 Mar 2009, 07:18 PM

 

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

 

1 Answer, 1 is accepted

Sort by
0
Pavlina
Telerik team
answered on 13 Mar 2009, 05:01 PM
Hi Henry,

In a hierarchical grid, each item in the Items collection of a parent GridTableView has a ChildItem property of type GridNestedViewItem. This child item is the container for the nested child table(s). The GridNestedViewItem has a NestedTableViews property that holds the collection of all the detail tables for the parent table.
You can use these properties to access the detail tables of a row in the parent table.

More information about accessing table views in a hierarchical grid is available in the following article:
Accessing cells and rows

Kind regards,

Pavlina
the Telerik team

 


Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Grid
Asked by
Henry Derstine
Top achievements
Rank 1
Answers by
Pavlina
Telerik team
Share this question
or