I have a radgrid which has user control edit form (webusercontrol),
inside which is another radgrid. In short, both grids have a
master/detail relationship. At the moment, I use dataset as the data
source, but bind it in the appropriate NeedDataSource event.
I want to commit changes to master/detail records in a single transaction, if there's a way to do this with a hierachy, I'm all ears.
When I edit a row in the master grid, webusercontrol appears, showing columns from selected row. Grid inside webusercontrol correctly shows related detail rows. But as soon as I click Edit, all rows disappear and grid says there are no records to display. This happens when I click Refresh as well.
I put a breakpoint in detail grid's NeedDataSource event, which vs hits. I checked there are data in the dataset.
I'm not loading user control dynamically. Same webusercontrol declared in the grid is used for insert and edit. I temporarily removed ajax manager to focus on the problem.
I already spent a day reading Telerik's extensive docs, demos and forums. I googled, yahooed, even binged, but search results point back to Telerik site anyway.
Any help is much appreciated.
Master
Detail
I want to commit changes to master/detail records in a single transaction, if there's a way to do this with a hierachy, I'm all ears.
When I edit a row in the master grid, webusercontrol appears, showing columns from selected row. Grid inside webusercontrol correctly shows related detail rows. But as soon as I click Edit, all rows disappear and grid says there are no records to display. This happens when I click Refresh as well.
I put a breakpoint in detail grid's NeedDataSource event, which vs hits. I checked there are data in the dataset.
I'm not loading user control dynamically. Same webusercontrol declared in the grid is used for insert and edit. I temporarily removed ajax manager to focus on the problem.
I already spent a day reading Telerik's extensive docs, demos and forums. I googled, yahooed, even binged, but search results point back to Telerik site anyway.
Any help is much appreciated.
Master
<telerik:RadGrid ID="rgHead" runat="server" ShowStatusBar="True" AutoGenerateColumns="False" AllowSorting="True" AllowPaging="True" GridLines="None" OnPreRender="rgHead_PreRender" OnNeedDataSource="rgHead_NeedDataSource" OnUpdateCommand="rgHead_UpdateCommand" OnInsertCommand="rgHead_InsertCommand" OnDeleteCommand="rgHead_DeleteCommand" OnItemCommand="rgHead_ItemCommand" onitemdatabound="rgHead_ItemDataBound"> <MasterTableView AllowSorting="True" DataKeyNames="RefNo" CommandItemDisplay="Top" Name="Head"> <Columns> <telerik:GridButtonColumn Text="Delete" CommandName="Delete" UniqueName="DeleteCommandColumn"> </telerik:GridButtonColumn> <telerik:GridTemplateColumn DataField="RefNo" SortExpression="RefNo" UniqueName="RefNo"> <EditItemTemplate> <asp:TextBox ID="Textbox1" runat="server" Text='<%# Bind("RefNo") %>'></asp:TextBox> </EditItemTemplate> <ItemTemplate> <asp:Label ID="Label1" runat="server" Text='<%# Eval("RefNo") %>'></asp:Label> </ItemTemplate> </telerik:GridTemplateColumn> <telerik:GridBoundColumn DataField="Description" ReadOnly="True" UniqueName="Description" HeaderText="Description"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="Rate" ReadOnly="True" UniqueName="Rate" HeaderText="Rate"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="Active" ReadOnly="True" UniqueName="Active" HeaderText="Active" DataType="System.Boolean"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="LastUpdateDate" UniqueName="LastUpdateDate" HeaderText="Last Updated"> </telerik:GridBoundColumn> <telerik:GridEditCommandColumn UniqueName="EditCommandColumn"> </telerik:GridEditCommandColumn> </Columns> <EditFormSettings UserControlName="~/Controls/DetailControl.ascx" EditFormType="WebUserControl"> <EditColumn UniqueName="EditCommandColumn1"> </EditColumn> </EditFormSettings> <PagerStyle PageSizeControlType="RadComboBox"></PagerStyle></telerik:RadGrid>protected void rgHead_NeedDataSource(object sender, GridNeedDataSourceEventArgs e){ rgHead.DataSource = ds.Tables["tblHead"];}Detail
<telerik:RadGrid ID="rgItems" runat="server" AllowSorting="True" AutoGenerateColumns="False" CellSpacing="0" GridLines="None" OnNeedDataSource="rgItems_NeedDataSource" Width="70%" OnDeleteCommand="rgItems_DeleteCommand" OnInsertCommand="rgItems_InsertCommand" OnItemCommand="rgItems_ItemCommand" OnUpdateCommand="rgItems_UpdateCommand" OnItemDataBound="rgItems_ItemDataBound"> <MasterTableView CommandItemDisplay="Top" ClientDataKeyNames="ItemNo" DataKeyNames="ItemNo" EditMode="EditForms"> <RowIndicatorColumn Visible="True"> </RowIndicatorColumn> <CommandItemSettings ExportToPdfText="Export to PDF"></CommandItemSettings> <ExpandCollapseColumn Visible="True"> <HeaderStyle Width="20px"></HeaderStyle> </ExpandCollapseColumn> <Columns> <telerik:GridButtonColumn CommandName="DeleteItem" Text="Delete" UniqueName="DeleteColumn"> </telerik:GridButtonColumn> <telerik:GridBoundColumn DataField="ItemNo" HeaderText="Item No" UniqueName="ItemNo"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="DiscountRate" HeaderText="Discount Rate (%)" UniqueName="DiscountRate"> </telerik:GridBoundColumn> <telerik:GridEditCommandColumn UniqueName="EditCommandColumn2"> </telerik:GridEditCommandColumn> </Columns> <EditFormSettings> <EditColumn UniqueName="EditCommandColumn2"> </EditColumn> </EditFormSettings> <PagerStyle PageSizeControlType="RadComboBox"></PagerStyle> </MasterTableView> <PagerStyle PageSizeControlType="RadComboBox"></PagerStyle> <FilterMenu EnableImageSprites="False"> </FilterMenu></telerik:RadGrid>protected void rgItems_NeedDataSource(object sender, GridNeedDataSourceEventArgs e){ rgItems.DataSource = ds.Tables["tblDetails"].Select("RefNo='" + (string)DataBinder.Eval(DataItem, "RefNo") + "'");}