Hi,
I want to be able to access a radGridthat is nested inside a radGrid then populate the nested radGrid from theOnEditCommand of the parent radGrid.
For example: radGrid1 containsradGrid2 within the EditFormSettings.FormTemplate. OnItemCommand, I want todisplay custom formatting for my edit form as well as a new radGrid with otherinformation. Is this possible?
I have tried using thee.item.findControl(“radGrid2”) from the GridCommandEventArgs, but null isreturned. In fact, any object I have within the EditFormSettings.FormTemplateseems to be inaccessible using this syntax. Since this didn’t work, I triediterating through the radGrid1’s items and searched for theGridItemType.EditFormItem and tried locating radGrid2 that way, but also wasunsuccessful.
protected void RadGrid1_OnEditCommand( object sender, GridCommandEventArgs e ) |
{ |
RadGrid masterGrid = (RadGrid) sender; |
foreach ( GridItem gi in masterGrid.Items ) |
{ |
if ( gi.ItemType == GridItemType.EditFormItem ) |
{ |
TextBox textBox1 = (TextBox) e.Item.FindControl( "txtCreditorName" ); |
RadGrid radGrid2 = (RadGrid) e.Item.FindControl( "RadGrid2" ); |
} |
} |
} |
I looked into the thread whichis talking about <NestedViewTemplate> but that is different from what Iwanted to do.
Can you please take a look at it? Anyhelp would be greatly appreciated.
Here is my code in aspxpage.
<telerik:RadGrid ID="RadGrid1" runat="server" AllowPaging="True" AllowSorting="True" Width="100%" |
AutoGenerateColumns="False" GridLines="None" Height="100%" onneeddatasource="RadGrid1_NeedDataSource" |
onupdatecommand="RadGrid1_UpdateCommand" oneditcommand="RadGrid1_EditCommand" onupdatecommand="RadGrid1_InsertCommand"> |
<PagerStyle Mode="NumericPages" AlwaysVisible="True" /> |
<MasterTableView CommandItemDisplay="Top" Width="100%" AllowMultiColumnSorting="True" EditMode="PopUp" |
DataKeyNames="creditor_id" Name="creditor"> |
<Columns> |
<telerik:GridEditCommandColumn ButtonType="ImageButton" UniqueName="EditCommandColumn"> |
<HeaderStyle Width="30px" /> |
<ItemStyle CssClass="MyImageButton" /> |
</telerik:GridEditCommandColumn> |
<telerik:GridBoundColumn SortExpression="creditor_id" HeaderButtonType="TextButton" DataField="creditor_id" |
HeaderText="Creditor Id" UniqueName="creditor_id" ReadOnly="true" Display="false"> |
</telerik:GridBoundColumn> |
<telerik:GridBoundColumn SortExpression="Name" HeaderButtonType="TextButton" DataField="Name" HeaderText="Creditor Name" |
UniqueName="Name"> |
</telerik:GridBoundColumn> |
</Columns> |
<EditFormSettings EditFormType="Template" PopUpSettings-Height="300px" PopUpSettings-Width="450px"> |
<EditColumn UniqueName="EditCommandColumn1"> |
</EditColumn> |
<FormTemplate> |
<table id="tblCreditor" cellspacing="5" cellpadding="1" width="450" border="0" rules="none"> |
<tr> |
<td> |
Creditor Name: |
</td> |
<td> |
<asp:TextBox ID="txtCreditorName" runat="server" Text='<%# Bind( "Name") %>'> </asp:TextBox> |
</td> |
</tr> |
<tr> |
<td> |
<telerik:RadGrid ID="RadGrid2" runat="server" Width="100%"> |
<PagerStyle Mode="NumericPages" AlwaysVisible="True" /> |
<MasterTableView CommandItemDisplay="Top" Width="100%" AllowMultiColumnSorting="True" |
DataKeyNames="person_id" Name="contact"> |
<Columns> |
<telerik:GridEditCommandColumn ButtonType="ImageButton" UniqueName="EditCommandColumn2"> |
<HeaderStyle Width="30px" /> |
<ItemStyle CssClass="MyImageButton" /> |
</telerik:GridEditCommandColumn> |
<telerik:GridBoundColumn SortExpression="person_id" HeaderText="Person Id" HeaderButtonType="TextButton" |
DataField="person_id" UniqueName="person_id" ReadOnly="true" Display="false"> |
</telerik:GridBoundColumn> |
<telerik:GridBoundColumn SortExpression="Name" HeaderText="Contact Name" HeaderButtonType="TextButton" |
DataField="Name" UniqueName="Name"> |
</telerik:GridBoundColumn> |
<telerik:GridBoundColumn SortExpression="Description" HeaderText="Description" HeaderButtonType="TextButton" |
DataField="Description" UniqueName="Description"> |
</telerik:GridBoundColumn> |
</Columns> |
</MasterTableView> |
</telerik:RadGrid> |
</td> |
</tr> |
<tr> |
<td align="center" colspan="2"> |
<asp:Button ID="btnUpdate" Text='<%# (Container is GridEditFormInsertItem) ? "Insert" : "Update" %>' |
runat="server" CommandName='<%# (Container is GridEditFormInsertItem) ? "PerformInsert" : "Update" %>' |
ValidationGroup="creditor" TabIndex="7"></asp:Button> |
<asp:Button ID="btnCancel" Text="Cancel" runat="server" CausesValidation="False" CommandName="Cancel" |
TabIndex="8"> |
</asp:Button> |
</td> |
</tr> |
</table> |
</FormTemplate> |
<PopUpSettings Height="300px" Width="450px"></PopUpSettings> |
</EditFormSettings> |
</MasterTableView> |
</telerik:RadGrid> |