| <telerik:RadGrid OnDetailTableDataBind="GrdSysApps_DetailTableDataBind" ID="GrdSysApps" |
| runat="server" OnNeedDataSource="GrdSysApps_OnNeedDataSource" AllowMultiRowSelection="True" |
| ClientSettings-Scrolling-AllowScroll="true" AutoGenerateColumns="False" Width="99%" |
| ClientSettings-Scrolling-ScrollHeight="150" GridLines="None" ShowGroupPanel="true" |
| ClientSettings-Scrolling-SaveScrollPosition="true" ClientSettings-Scrolling-UseStaticHeaders="true" |
| AllowFilteringByColumn="true" AllowSorting="true" ClientSettings-AllowColumnsReorder="false"> |
| <MasterTableView DataKeyNames="SystemApplicationID" ClientDataKeyNames="SystemApplicationID"> |
| <RowIndicatorColumn> |
| <HeaderStyle Width="20px"></HeaderStyle> |
| </RowIndicatorColumn> |
| <ExpandCollapseColumn> |
| <HeaderStyle Width="20px"></HeaderStyle> |
| </ExpandCollapseColumn> |
| <Columns> |
| <telerik:GridBoundColumn DataField="SystemApplicationID" EmptyDataText="&nbsp;" |
| UniqueName="column" Visible="False"> |
| </telerik:GridBoundColumn> |
| <custom:CustomClientSelectColumn UniqueName="SelectedRows"> |
| <FilterTemplate> |
| <asp:DropDownList Font-Size="X-Small" ID="cboGrdSysAppsFilter" AutoPostBack="true" |
| runat="server" OnSelectedIndexChanged="cboSelected_SelectedIndexChanged"> |
| <asp:ListItem>All</asp:ListItem> |
| <asp:ListItem>Selected</asp:ListItem> |
| <asp:ListItem>Not Selected</asp:ListItem> |
| </asp:DropDownList> |
| </FilterTemplate> |
| </custom:CustomClientSelectColumn> |
| <telerik:GridBoundColumn DataField="Name" EmptyDataText="&nbsp;" HeaderText="Name" |
| UniqueName="column2"> |
| </telerik:GridBoundColumn> |
| <telerik:GridBoundColumn DataField="Description" EmptyDataText="&nbsp;" HeaderText="Description" |
| UniqueName="column3"> |
| </telerik:GridBoundColumn> |
| <telerik:GridBoundColumn DataField="ManagerDel" EmptyDataText="&nbsp;" HeaderText="Mgr Approver" |
| UniqueName="column5"> |
| </telerik:GridBoundColumn> |
| <telerik:GridBoundColumn DataField="DirectorDel" EmptyDataText="&nbsp;" HeaderText="Dir Approver" |
| UniqueName="column9"> |
| </telerik:GridBoundColumn> |
| <telerik:GridBoundColumn DataField="Director2Del" EmptyDataText="&nbsp;" HeaderText="Dir2 Approver" |
| UniqueName="column6"> |
| </telerik:GridBoundColumn> |
| </Columns> |
| <DetailTables> |
| <telerik:GridTableView DataKeyNames="SystemApplicationID" HierarchyLoadMode="ServerOnDemand" |
| AllowSorting="false" AllowFilteringByColumn="false" Name="OriginalOwners"> |
| <ParentTableRelation> |
| <telerik:GridRelationFields MasterKeyField="SystemApplicationID" DetailKeyField="SystemApplicationID" /> |
| </ParentTableRelation> |
| <Columns> |
| <telerik:GridBoundColumn HeaderText="Default System Manager" HeaderButtonType="TextButton" |
| DataField="Manager"> |
| </telerik:GridBoundColumn> |
| <telerik:GridBoundColumn HeaderText="Default System Director" HeaderButtonType="TextButton" |
| DataField="Director"> |
| </telerik:GridBoundColumn> |
| <telerik:GridBoundColumn HeaderText="Default System 2nd Director" HeaderButtonType="TextButton" |
| DataField="Director2"> |
| </telerik:GridBoundColumn> |
| </Columns> |
| </telerik:GridTableView> |
| </DetailTables> |
| </MasterTableView> |
| <ClientSettings AllowDragToGroup="true"> |
| <Selecting AllowRowSelect="true" /> |
| <ClientEvents OnRowSelected="GrdSysApps_RowSelected" OnRowDeselected="GrdSysApps_RowDeselected" |
| OnRowCreated="GrdSysApps_RowCreated" OnCommand="RaiseCommand" /> |
| </ClientSettings> |
| <FilterMenu EnableTheming="True"> |
| <CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation> |
| </FilterMenu> |
| </telerik:RadGrid> |
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
RadGrid
grid = new RadGrid();
grid.ID =
"radGridProducts";
grid.AutoGenerateColumns =
false;
grid.AllowSorting =
true;
grid.AllowMultiRowSelection =
true;
grid.AllowMultiRowEdit =
true;
grid.GridLines =
GridLines.None ;
//grid.Width = Unit.Percentage(100);
//grid.MasterTableView.TableLayout = GridTableLayout.Fixed;
grid.Height =
Unit.Pixel(380);
String htmlColor = "#EDEFF1";
Color backColor = ColorTranslator.FromHtml(htmlColor);
grid.AlternatingItemStyle.BackColor = backColor;
//grid.BorderColor = Color.Blue;
grid.MasterTableView.AllowPaging =
true;
grid.MasterTableView.PagerStyle.AlwaysVisible =
true;
grid.MasterTableView.PagerStyle.Position =
GridPagerPosition.TopAndBottom;
grid.MasterTableView.PagerStyle.Mode =
GridPagerMode.NextPrevNumericAndAdvanced;
grid.ClientSettings.AllowKeyboardNavigation =
true;
grid.ClientSettings.Selecting.AllowRowSelect=
true;
grid.ClientSettings.Scrolling.AllowScroll =
true;
grid.ClientSettings.Scrolling.UseStaticHeaders =
true;
grid.ClientSettings.Scrolling.ScrollHeight =
Unit.Pixel(300);
grid.FilterMenu.EnableTheming=
true;
grid.FilterMenu.CollapseAnimation.Duration = 200;
grid.FilterMenu.CollapseAnimation.Type =
AnimationType.OutQuint;
//Add Products Master table
grid.MasterTableView.Name =
"ProductParent";
grid.MasterTableView.PageSize = 30;
grid.MasterTableView.DataKeyNames =
new string[] { "Id", "ParentId","ProductLevel","Tag"};
grid.MasterTableView.EditMode =
GridEditMode.InPlace;
//grid.MasterTableView.TableLayout = GridTableLayout.Fixed;
GridEditCommandColumn col0 = new GridEditCommandColumn();
col0.ButtonType =
GridButtonColumnType.ImageButton;
col0.UpdateImageUrl =
"../images/Update.gif";
col0.EditImageUrl =
"../images/Edit.gif";
col0.InsertImageUrl =
"../images/Insert.gif";
col0.CancelImageUrl =
"../images/Cancel.gif";
col0.UniqueName =
"EditCommandColumn";
grid.MasterTableView.Columns.Add(col0);
//grid.MasterTableView.Columns[0].HeaderStyle.Width = Unit.Percentage(4);
//grid.MasterTableView.Columns[0].HeaderStyle.Width = Unit.Pixel(30);
GridButtonColumn col1 = new GridButtonColumn();
col1.Text =
"Delete";
col1.ConfirmText =
"Delete this product?";
col1.ButtonType =
GridButtonColumnType.ImageButton;
col1.ImageUrl =
"../images/Delete.gif";
col1.CommandName =
"Delete";
col1.UniqueName =
"DeleteColumn";
grid.MasterTableView.Columns.Add(col1);
//grid.MasterTableView.Columns[1].HeaderStyle.Width = Unit.Percentage(3);
//grid.MasterTableView.Columns[1].HeaderStyle.Width = Unit.Pixel(30);
GridClientSelectColumn col2 = new GridClientSelectColumn();
col2.UniqueName =
"checkBoxColumn";
grid.MasterTableView.Columns.Add(col2);
//grid.MasterTableView.Columns[2].HeaderStyle.Width = Unit.Percentage(4);
//grid.MasterTableView.Columns[2].HeaderStyle.Width = Unit.Pixel(30);
GridBoundColumn col3 = new GridBoundColumn();
col3.DataField =
"Tag";
col3.UniqueName = grid.MasterTableView.Name +
"colTag";
col3.HeaderText =
"Tag";
//col3.ReadOnly = true;
grid.MasterTableView.Columns.Add(col3);
//grid.MasterTableView.Columns[3].HeaderStyle.Width = Unit.Percentage(15);
GridBoundColumn col4 = new GridBoundColumn();
col4.DataField =
"ShortDescription";
col4.UniqueName = grid.MasterTableView.Name +
"colShortDescription";
col4.HeaderText =
"Short Description";
col3.MaxLength = 40;
grid.MasterTableView.Columns.Add(col4);
//grid.MasterTableView.Columns[4].HeaderStyle.Width = Unit.Percentage(15);
GridBoundColumn col5 = new GridBoundColumn();
col5.DataField =
"LongDescription";
col5.UniqueName = grid.MasterTableView.Name +
"colLongDescription";
col5.HeaderText =
"Long Description";
col5.MaxLength = 80;
grid.MasterTableView.Columns.Add(col5);
//grid.MasterTableView.Columns[5].HeaderStyle.Width = Unit.Percentage(25);
GridBoundColumn col6 = new GridBoundColumn();
col6.DataField =
"ShortDescription2";
col6.UniqueName = grid.MasterTableView.Name +
"colShortDescription2";
col6.HeaderText =
"Short Description 2";
col6.MaxLength = 40;
grid.MasterTableView.Columns.Add(col6);
//grid.MasterTableView.Columns[6].HeaderStyle.Width = Unit.Percentage(15);
GridHyperLinkColumn col7 = new GridHyperLinkColumn();
col7.UniqueName = grid.MasterTableView.Name +
"colCharacteristics2";
col7.HeaderText =
"Characteristics";
col7.DataNavigateUrlFields =
new string[] { "Id", "LongDescription" };
col7.DataNavigateUrlFormatString =
"javascript:ShowCharacteristics('{0}', '{1}');";
col7.Text =
"View";
grid.MasterTableView.Columns.Add(col7);
grid.MasterTableView.Columns[7].HeaderStyle.Width =
Unit.Percentage(10);
//grid.MasterTableView.Columns[7].HeaderStyle.Width = Unit.Pixel(50);
GridHyperLinkColumn col8 = new GridHyperLinkColumn();
col8.UniqueName = grid.MasterTableView.Name +
"colSRP";
col8.HeaderText =
"Quality Checks";
col8.DataNavigateUrlFields =
new string[] { "Id", "LongDescription" };
col8.DataNavigateUrlFormatString =
"javascript:ShowSRPs('{0}','{1}');";
col8.DataTextField =
"SRPViewText";
//col8.Text = "View";
grid.MasterTableView.Columns.Add(col8);
grid.MasterTableView.Columns[8].HeaderStyle.Width =
Unit.Percentage(10);
//grid.MasterTableView.Columns[8].HeaderStyle.Width = Unit.Pixel(50);
grid.NeedDataSource +=
new GridNeedDataSourceEventHandler(this.RadGridProducts_NeedDataSource);
grid.DetailTableDataBind +=
new GridDetailTableDataBindEventHandler(this.RadGridProducts_DetailTableDataBind);
grid.DeleteCommand +=
new GridCommandEventHandler(this.radGridProducts_DeleteCommand);
grid.UpdateCommand +=
new GridCommandEventHandler(this.RadGridProducts_UpdateCommand);
grid.InsertCommand +=
new GridCommandEventHandler(this.RadGridProducts_InsertCommand);
grid.ItemDataBound +=
new GridItemEventHandler(this.RadGridProducts_ItemDataBound);
grid.MasterTableView.CommandItemTemplate =
new ProductCommandItemTemplate();
grid.MasterTableView.CommandItemDisplay =
GridCommandItemDisplay.Top;
// Add the grid to the placeholder
this.PlaceHolder1.Controls.Add(grid);

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. |
|
| <asp:Panel runat="server" ID="pnlDocks"> |
| <telerik:RadDockLayout runat="server" ID="radDockLayout" Skin="Default" /> |
| <telerik:RadDockZone runat="server" ID="radDockingZone" Orientation="Vertical" BorderStyle="None" BackColor="Transparent"> |
| <telerik:RadDock runat="server" ID="rdo" Title="My Title" |
| Width="520px" Height="60px" Visible="false" Resizable="false" |
| DockHandle="TitleBar" Collapsed="false"> |
| <ContentTemplate> |
| ... |
| </ContentTemplate> |
| </telerik:RadDock> |
| </telerik:RadDockZone> |
| </asp:Panel> |