Folks,
I have a Heirarchical Grid (MasterTableView and DetailTables both uses FormTemplate). Is it possible while I am in DetailTable Edit/Insert mode, populate a label named (MasterTableUserFullName) in DetailTable with the Last+FirstName column values from MasterTableView?
In my RadGrid1_ItemDatabound event, I am able to populate that label (MasterTableUserFullName) with a string “Hellow World” but unsucessful to populate it with MasterTableView Last+FirstName Values.
Below is my code. Any help will be appreciated.
Thanks
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
{
if ((e.Item is GridEditableItem && e.Item.IsInEditMode))
{
GridDataItem parentItem = e.Item.OwnerTableView.ParentItem as GridDataItem;
if (parentItem != null)
{
GridEditableItem item = (GridEditableItem)e.Item;
Label txt = (Label)item.FindControl("MasterTableUserFullName");
txt.Text = "Hellow World"; // This Works ...
// but need to update the label Box with MasterTableView Last + First Name Values.
}
}
}
_____________________________
<telerik:RadGrid ID="RadGrid1" runat="server" AllowAutomatic Inserts/Deletes/Updatess ="True" onitemdatabound="RadGrid1_ItemDataBound">
<MasterTableView datakeynames="UserTablePrimaryKey" datasourceid="SqlDataSource1" AllowFilteringByColumn = "true" CommandItemDisplay="TopAndBottom">
<!—Beginning Block of Child DetailTable -->
<DetailTables>
<telerik:GridTableView runat="server" DataSourceID="SqlDataSource2" DataKeyNames="UserLocationsPrimaryKey"
Width="100%" CommandItemDisplay= "TopAndBottom" Name = "Detail" AllowAutomatic Inserts/Deletes/Updates ="True">
<ParentTableRelation>
<telerik:GridRelationFields DetailKeyField="UserTableForeignKey" MasterKeyField="UserTablePrimaryKey" /> </ParentTableRelation>
<Columns>
<telerik:GridBoundColumn DataField="UserTableForeignKey"
DataType="System.Int32" HeaderText="UserTableForeignKey"
SortExpression="UserTableForeignKey" UniqueName="UserTableForeignKey"
Display="False" ReadOnly="True" Visible="False">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="Program" HeaderText="Program" HeaderStyle-Width="50%"
SortExpression="Program" UniqueName="Program" >
<HeaderStyle Width="50%"></HeaderStyle>
</telerik:GridBoundColumn>
.
.
.
</Columns>
<EditFormSettings EditFormType="Template">
<EditColumn UniqueName="EditCommandColumn1"></EditColumn>
<FormTemplate>
<table id="Table1" cellspacing="2" cellpadding="1" width="100%" border="0" rules="none"
style="border-collapse: collapse; background: white;">
<tr>
<td colspan="2" style="font-size:small; z-index:0; font-family:Bookman Old Style; color:#669999">
<asp:Label ID="MasterTableUserFullName" runat="server" Text="User Location" Font-Underline="True">
</asp:Label>
</td>
</tr>
.
.
.
</table>
</FormTemplate>
</EditFormSettings>
</telerik:GridTableView>
</DetailTables>
<!—Ending Block of Child DetailTable -->
<!—Beginning Block of MasterTableView -->
<Columns>
<telerik:GridBoundColumn DataField="UserTablePrimaryKey"
DataType="System.Int32" HeaderText="UserTablePrimaryKey" ReadOnly="True"
SortExpression="UserTablePrimaryKey" UniqueName="UserTablePrimaryKey"
Visible="False">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="Last_Name" HeaderText="Last Name"
SortExpression="Last_Name" UniqueName="Last_Name">
<HeaderStyle Width="18%" />
<ItemStyle Width="18%" />
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="First_Name" HeaderText="First Name"
SortExpression="First_Name" UniqueName="First_Name">
<HeaderStyle Width="18%" />
<ItemStyle Width="18%" />
</telerik:GridBoundColumn>
</Columns>
<EditFormSettings EditFormType="Template">
<FormTemplate>
<table id="Table2">
<tr>
<td>
Last Name</td>
<td>
<asp:TextBox ID="TxtLast_Name" runat="server" Text='<%# Bind( "Last_Name") %>' TabIndex="1"> </asp:TextBox>
</td>
<td>
First Name</td>
<td>
<asp:TextBox ID="TxtFirst_Name" runat="server" Text='<%# Bind( "First_Name") %>' TabIndex="2"> </asp:TextBox>
</td>
</tr>
.
.
.
</table>
</FormTemplate>
</EditFormSettings>
.
.
.
</MasterTableView>
<!— Ending Block of MasterTableView -->
</telerik:RadGrid>