protected void rgRequest_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e) { if (e.Item is GridDataItem && e.Item.IsInEditMode) { GridDataItem item = (GridDataItem)e.Item; ImageButton image = (ImageButton)e.Item.FindControl("UpdateButton"); image.CausesValidation = false; image.Click += new ImageClickEventHandler(image_Click); } } <%@ Control Language="C#" AutoEventWireup="true" CodeBehind="Test.ascx.cs" Inherits="WebApplication4.Test" %><%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %><h4> Scenario Lab Management</h4><asp:Label ID="lblId" runat="server"></asp:Label>:<asp:Label ID="lblValue" runat="server"></asp:Label><telerik:RadGrid ID="radSIFMAHypotheticalMaintenance" runat="server" AutoGenerateColumns="False" PageSize="25" AllowAutomaticUpdates="True"> <MasterTableView Width="100%" PageSize="25" AutoGenerateColumns="False"> <Columns> <telerik:GridButtonColumn ButtonType="LinkButton" UniqueName="EditCommandColumn" CommandName="Edit" Text="Edit" /> <telerik:GridBoundColumn DataField="MaturityType" HeaderText="Maturity" SortExpression="" ReadOnly="true" /> <telerik:GridBoundColumn DataField="Sequence" HeaderText="Sequence" SortExpression="" ReadOnly="true" /> <telerik:GridNumericColumn UniqueName="SIFMA" SortExpression="SIFMA" HeaderText="SIFMA" DataType="System.Decimal" DataField="Rate" ColumnEditorID="GridNumericColumnEditor1"> </telerik:GridNumericColumn> </Columns> </MasterTableView> <ClientSettings> <Selecting AllowRowSelect="true" /> </ClientSettings></telerik:RadGrid><telerik:GridNumericColumnEditor ID="GridNumericColumnEditor1" runat="server"> <NumericTextBox MaxLength="25" EmptyMessage="Percentage."> <NumberFormat GroupSeparator="" DecimalDigits="2" /> </NumericTextBox></telerik:GridNumericColumnEditor><telerik:RadGrid ID="radLIBOR" runat="server" AutoGenerateColumns="False" PageSize="25"> <MasterTableView Width="100%" CommandItemDisplay="None" PageSize="25" AutoGenerateColumns="False" EditMode="EditForms"> <Columns> <telerik:GridButtonColumn ButtonType="LinkButton" UniqueName="EditCommandColumn" CommandName="Edit" Text="Edit" /> <telerik:GridBoundColumn DataField="maturityType" HeaderText="Maturity" SortExpression="" ReadOnly="true" /> <telerik:GridBoundColumn HeaderText="Sequence" DataField="sequence" SortExpression="" ReadOnly="true" /> <telerik:GridNumericColumn UniqueName="LIBOR" SortExpression="LIBOR" HeaderText="LIBOR" DataType="System.Decimal" DataField="rate" ColumnEditorID="GridNumericColumnEditor2"> </telerik:GridNumericColumn> </Columns> </MasterTableView> <ClientSettings> <Selecting AllowRowSelect="true" /> </ClientSettings></telerik:RadGrid><telerik:GridNumericColumnEditor ID="GridNumericColumnEditor2" runat="server"> <NumericTextBox MaxLength="25" EmptyMessage="Percentage."> <NumberFormat GroupSeparator="" DecimalDigits="2" /> </NumericTextBox></telerik:GridNumericColumnEditor>using System;namespace WebApplication4{ public partial class Test : System.Web.UI.UserControl { protected void Page_Load(object sender, EventArgs e) { } public void LoadData(TestData td) { lblId.Text = td.id.ToString(); lblValue.Text = td.var1.ToString(); radSIFMAHypotheticalMaintenance.DataSource = td.sifmaList; radLIBOR.DataSource = td.liborList; radSIFMAHypotheticalMaintenance.DataBind(); radLIBOR.DataBind(); } }}Default.aspx:
<%@ Page Title="Home Page" Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebApplication4._Default" %><%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %><html xmlns="http://www.w3.org/1999/xhtml"><head id="Head1" runat="server"> <title></title></head><body> <form id="form1" runat="server"> <telerik:RadScriptManager ID="RadScriptManager1" runat="server"> </telerik:RadScriptManager> <telerik:RadTabStrip ID="RadTabStrip1" Width="100%" runat="server" MultiPageID="RadMultiPage1" SelectedIndex="0"> </telerik:RadTabStrip> <telerik:RadMultiPage ID="RadMultiPage1" runat="server" SelectedIndex="0"> </telerik:RadMultiPage> </form></body></html>using System;using System.Collections.Generic;using Telerik.Web.UI;namespace WebApplication4{ public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { if (!this.IsPostBack) { List<TestData> lst = DataSetUp(); foreach (var item in lst) { RadTab tab = new RadTab(); tab.Text = item.tabName; tab.PageViewID = item.id.ToString(); RadTabStrip1.Tabs.Add(tab); RadPageView pageView = new RadPageView(); pageView.ID = item.id.ToString(); Test userControl = this.LoadControl("~/Test.ascx") as Test; userControl.LoadData(item as TestData); pageView.Controls.Add(userControl); RadMultiPage1.PageViews.Add(pageView); } } } private static List<TestData> DataSetUp() { List<TestData> lst = new List<TestData>(); List<LIBOR> liborLst = new List<LIBOR>(); liborLst.Add(new LIBOR { maturityType = "Weekly", rate = 25.5, sequence = 100 }); liborLst.Add(new LIBOR { maturityType = "Monthly", rate = 35.5, sequence = 1001324 }); List<SIFMA> sifmaLst = new List<SIFMA>(); sifmaLst.Add(new SIFMA { maturityType = "Weekly", rate = 45.5, sequence = 1000 }); sifmaLst.Add(new SIFMA { maturityType = "Monthly", rate = 55.5, sequence = 10013240 }); var test = new TestData { id = 1, tabName = "10 Year Average", var1 = "string1", var2 = "string11", liborList = liborLst, sifmaList = sifmaLst }; lst.Add(test); List<LIBOR> liborLst2 = new List<LIBOR>(); liborLst2.Add(new LIBOR { maturityType = "Quarterly", rate = 65.5, sequence = 10 }); liborLst2.Add(new LIBOR { maturityType = "Yearly", rate = 75.5, sequence = 10013 }); List<SIFMA> sifmaLst2 = new List<SIFMA>(); sifmaLst2.Add(new SIFMA { maturityType = "Quarterly", rate = 85.5, sequence = 1 }); sifmaLst2.Add(new SIFMA { maturityType = "Yearly", rate = 95.5, sequence = 100 }); var test2 = new TestData { id = 2, tabName = "1987 Crash", var1 = "string2", var2 = "string22", liborList = liborLst2, sifmaList = sifmaLst2 }; lst.Add(test2); return lst; } } public class TestData { public int id; public string tabName; public string var1; public string var2; public List<LIBOR> liborList; public List<SIFMA> sifmaList; } public class LIBOR { public string maturityType; public double rate; public int sequence; public string MaturityType { get { return maturityType; } } public double Rate { get { return rate; } } public int Sequence { get { return sequence; } } } public class SIFMA { public string maturityType; public double rate; public int sequence; public string MaturityType { get { return maturityType; } } public double Rate { get { return rate; } } public int Sequence { get { return sequence; } } }}.RadListBox
.rlbGroup .rlbActive
{
border: 1px dotted #555;
padding: 1px 4px;
}
rgrdStatus.MasterTableView.DetailTables[0].ParentItem.GetDataKeyValue(
"Id")
the ParentItem is always null!
Thanks!
I am trying to bind to my labels in my nestedview template in my radgrid, but looking at telerik site but have not been able to find how they bind throught he code behind page and get a hold of the data key in the parenttablerelation. How can I bind to my controls via code behind page. I thought through the detialtabledatabind but nothing works for nested views.
Protected Sub myGridDeploy_DetailTableDataBind(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridDetailTableDataBindEventArgs) Handles myGridDeploy.DetailTableDataBind
If e.DetailTableView.Name = "myUnitPos" Then
sql = "Select intPositionId, intUnitMobId, strPosnTitle, strPara, strLine, intPositionNum, strGrade, strMOS, strASI, strAuthBr, Case when intAsgnstr = 0 " _
& "then 'NO' else 'YES' end Filled From tblMobUnitPosition where intUnitMobID = " & e.DetailTableView.ParentItem.GetDataKeyValue("intUnitMobId") & " " _
& "order by strPara, strLine, intPositionNum"
e.DetailTableView.DataSource = getData(sql)
End If
sql = "Select intDeployId,intPositionId,si.FullName,si.strRank,si.AGE,si.strPmos,si.strSMOS,si.POSN_NBR_EXCESS_IND,si.SCTY_CLNC,si.ETS,si.strstatus,si.PHYS_PRFL_SER,si.intYearSvc, si.SRpDate,si.Deployable, " _
& "si.email From tblMobUnitPersonnel as up LEFT JOIN vw_Soldierinfo as si on si.strssn = up.strSSN where up.intPositionId = " & e.DetailTableView.ParentItem.GetDataKeyValue("intPositionId") & ""
End Sub
<telerik:GridTableView DataKeyNames="intPositionId" Name="myUnitPos" Width="100%" TableLayout="Fixed" BorderWidth="1px" CellPadding="6" Font-Size="10"
AutoGenerateColumns="False" HeaderStyle-HorizontalAlign="Center" BorderColor="#404040" Font-Names="Veranda,arial,sans-serif" GridLines="Both" ExpandCollapseColumn-ButtonType="ImageButton"
ExpandCollapseColumn-CollapseImageUrl="~/Images/30.png" ExpandCollapseColumn-ExpandImageUrl="~/Images/29.png">
<ParentTableRelation>
<telerik:GridRelationFields DetailKeyField="intUnitMobId" MasterKeyField="intUnitMobId" />
</ParentTableRelation>
<HeaderStyle Font-Bold="true" HorizontalAlign="Center" CssClass="InnerSubHeaderStyle" />
<ItemStyle CssClass="InnerSubItemStyle" HorizontalAlign="Center" />
<AlternatingItemStyle CssClass="InnerSubAlernatingItemStyle" HorizontalAlign="Center" />
<NestedViewSettings>
<ParentTableRelation>
<telerik:GridRelationFields DetailKeyField="intPositionId" MasterKeyField="intPositionId" />
</ParentTableRelation>
</NestedViewSettings>
<NestedViewTemplate>
<asp:Panel ID="pnlInfo" runat="server" BorderStyle="Double" BorderColor="#85A3E0" Width="50%">
<table >
<tr>
<td><u>Soldier Information</u></td>
</tr>
<tr>
<td style="height:5px"></td>
</tr>
<tr>
<td>
Name: <asp:Label ID="lblSoldier" runat="server" Text='<%#Bind("FUllName") %>'></asp:Label>
Rank: <asp:label ID="lblRank" runat="server" Text='<%#Bind("strRank") %>'></asp:label>
Age: <asp:Label ID="lblAge" runat="server" Text='<%#Bind("AGE") %>'></asp:Label>
</td>
</tr>
<tr>
<td style="height:5px"></td>
</tr>
<tr>
<td>
PMOS: <asp:Label ID="lblPMOS" runat="server"></asp:Label>
SMOS: <asp:label ID="lblSMOS" runat="server"></asp:label>
POSN Excess: <asp:Label ID="lblPOSN" runat="server"></asp:Label>
</td>
</tr>
<tr>
<td style="height:5px"></td>
</tr>
<tr>
<td>
Clearance: <asp:Label ID="lblClear" runat="server"></asp:Label>
ETS\MRD: <asp:label ID="lblEts" runat="server"></asp:label>
Full-Time: <asp:Label ID="lblFullTime" runat="server"></asp:Label>
</td>
</tr>
<tr>
<td style="height:5px"></td>
</tr>
<tr>
<td>
PULHES: <asp:Label ID="lblPuhles" runat="server"></asp:Label>
Yrs Active: <asp:label ID="lblYrsActive" runat="server"></asp:label>
</td>
</tr>
<tr>
<td style="height:5px"></td>
</tr>
<tr>
<td>
SRP Date: <asp:Label ID="lblDtSrp" runat="server"></asp:Label>
Deployable: <asp:label ID="lblDeplyable" runat="server"></asp:label>
</td>
</tr>
<tr>
<td style="height:5px"></td>
</tr>
<tr>
<td>
Email: <asp:Label ID="lblEmail" runat="server"></asp:Label>
</td>
</tr>
</table>
</asp:Panel>
</NestedViewTemplate>
<Columns>