I am working int he databound event trying to get the datakey value of my grid to populate my nestedview. I have a tope level grid then a subgrid and then a nestedview of this. how can i get the datakey of the second level grid to populate the nestedview values. I have tried this but no joy give me an error
item.OwnerTableView.DataKeyValues(item.ItemIndex)("intPositionId").ToString
Protected Sub myGridDeploy_ItemDataBound(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridItemEventArgs) Handles myGridDeploy.ItemDataBound
If TypeOf e.Item Is GridNestedViewItem Then
Dim item As GridNestedViewItem = DirectCast(e.Item, GridNestedViewItem)
sql = "Select mp.strSSN, 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, Deployable, si.Email " _
& "From tblPersonnel as mp LEFT JOIN vw_PersonrInfo as si on si.strSSN = mp.strSSN where intPositionId = " & item.OwnerTableView.DataKeyValues(item.ItemIndex)("intPositionId").ToString
myDataTable = New DataTable
myDataTable = getData(sql)
TryCast(item.FindControl("lblPerson"), Label).Text = myDataTable.Rows(0)(1)
TryCast(item.FindControl("lblRank"), Label).Text = myDataTable.Rows(0)(2
TryCast(item.FindControl("lblAge"), Label).Text = myDataTable.Rows(0)(3)
TryCast(item.FindControl("lblPmos"), Label).Text = myDataTable.Rows(0)(4)
If IsDBNull(myDataTable.Rows(0)(5)) Then
myDataTable.Rows(0)(5) = "None"
End If
TryCast(item.FindControl("lblSmos"), Label).Text = myDataTable.Rows(0)(5)
TryCast(item.FindControl("lblPosn"), Label).Text = myDataTable.Rows(0)(6)
TryCast(item.FindControl("lblClear"), Label).Text = myDataTable.Rows(0)(7)
TryCast(item.FindControl("lblEts"), Label).Text = myDataTable.Rows(0)(8)
TryCast(item.FindControl("lblFullTime"), Label).Text = myDataTable.Rows(0)(9)
TryCast(item.FindControl("lblPuhles"), Label).Text = myDataTable.Rows(0)(10)
TryCast(item.FindControl("lblYrsActive"), Label).Text = myDataTable.Rows(0)(11)
If IsDBNull(myDataTable.Rows(0)(12)) Then
myDataTable.Rows(0)(12) = "None"
End If
TryCast(item.FindControl("lblDtSrp"), Label).Text = myDataTable.Rows(0)(12)
TryCast(item.FindControl("lblDeplyable"), Label).Text = myDataTable.Rows(0)(13)
TryCast(item.FindControl("lblEmail"), Label).Text = myDataTable.Rows(0)(14)
End If
End Sub
What I have is a grid that contains a subgrid and then a nested view in the subgrid. I am trying to get a hold of the datakey of the subgrid to populate the nestedview automatically, Right now I have a static Id in the code to make sure it works but need to get the dynamic Id. This was given to me before but did not work. I got an error with it. how can I get a hold of the datakey for the sub grid to populate the nested view of the subgrid.
Protected Sub RadGrid1_ItemDataBound(sender As Object, e As GridItemEventArgs) If TypeOf e.Item Is GridDataItem Then Dim innergrid As RadGrid = DirectCast(sender, RadGrid) Dim nesteditem As GridNestedViewItem = DirectCast(innergrid.NamingContainer, GridNestedViewItem) Dim parentItem As GridDataItem = DirectCast(nesteditem.ParentItem, GridDataItem) Dim Id As String = parentItem.GetDataKeyValue("PositionId").ToString() End IfEnd SubDescription: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
|
Protected Sub myGridDeploy_ItemDataBound(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridItemEventArgs) Handles myGridDeploy.ItemDataBound
If TypeOf e.Item Is GridDataItem Then
Dim innergrid As RadGrid = DirectCast(sender, RadGrid)
Dim nesteditem As GridNestedViewItem = DirectCast(innergrid.NamingContainer, GridNestedViewItem)
Dim parentItem As GridDataItem = DirectCast(nesteditem.ParentItem, GridDataItem)
Dim Id As String = parentItem.GetDataKeyValue("PositionId").ToString()
End If
If TypeOf e.Item Is GridNestedViewItem Then
Dim item As GridNestedViewItem = DirectCast(e.Item, GridNestedViewItem)
sql = "Select mp.strSSN, 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, Deployable, " _
& "Case when mp.intDMOSQ = 1 then 'YES' ELSE 'NO' END intDMOSQ, si.Email " _
& "From tblMobUnitPersonnel as mp LEFT JOIN vw_SoldierInfo as si on si.strSSN = mp.strSSN where intPositionId = " & Id
myDataTable = New DataTable
myDataTable = getData(sql)
TryCast(item.FindControl("lblPersonnel"), Label).Text = myDataTable.Rows(0)(1)
TryCast(item.FindControl("lblRank"), Label).Text = myDataTable.Rows(0)(2)
TryCast(item.FindControl("lblAge"), Label).Text = myDataTable.Rows(0)(3)
TryCast(item.FindControl("lblPmos"), Label).Text = myDataTable.Rows(0)(4)
If IsDBNull(myDataTable.Rows(0)(5)) Then
myDataTable.Rows(0)(5) = "None"
End If
TryCast(item.FindControl("lblSmos"), Label).Text = myDataTable.Rows(0)(5)
TryCast(item.FindControl("lblPosn"), Label).Text = myDataTable.Rows(0)(6)
TryCast(item.FindControl("lblClear"), Label).Text = myDataTable.Rows(0)(7)
TryCast(item.FindControl("lblEts"), Label).Text = myDataTable.Rows(0)(8)
TryCast(item.FindControl("lblFullTime"), Label).Text = myDataTable.Rows(0)(9)
TryCast(item.FindControl("lblPuhles"), Label).Text = myDataTable.Rows(0)(10)
TryCast(item.FindControl("lblYrsActive"), Label).Text = myDataTable.Rows(0)(11)
If IsDBNull(myDataTable.Rows(0)(12)) Then
myDataTable.Rows(0)(12) = "None"
End If
TryCast(item.FindControl("lblDtSrp"), Label).Text = myDataTable.Rows(0)(12)
TryCast(item.FindControl("lblDeplyable"), Label).Text = myDataTable.Rows(0)(13)
TryCast(item.FindControl("lblDMOSQ"), Label).Text = myDataTable.Rows(0)(14)
TryCast(item.FindControl("lblEmail"), Label).Text = myDataTable.Rows(0)(15)
End If
End Sub
<telerik:GridTemplateColumn HeaderText="Action" UniqueName="tplColAction"> <ItemTemplate> <asp:Panel ID="pnlActionStatut" runat="server" HorizontalAlign="left"> </asp:Panel> </ItemTemplate> </telerik:GridTemplateColumn>protected void rdGridOpportunite_ItemDataBound(object sender, GridItemEventArgs e) { if (e.Item.ItemType != GridItemType.Item && e.Item.ItemType != GridItemType.AlternatingItem) return; //Get Object Entity OpportuniteEntity opp = e.Item.DataItem as OpportuniteEntity; if (opp == null) return; //Get Panel Control pnl = e.Item.FindControl("pnlActionStatut"); if (!(pnl is Panel)) return; //Get All statut associate of this statut List<TypeStatutOpportuniteEntity> statuts = TypeManager.GetStatutAssocieOfStatut(opp.TypeStatut.IDType, Profile.InstanceID).ToList(); if (statuts.Count == 0) return; LinkButton lbAction; //Create LinkButton for each Statut statuts.ForEach(s => { lbAction = new LinkButton(); lbAction.Text = "--> " + s.Libelle; lbAction.Click += new EventHandler(lbAction_Click); lbAction.CommandArgument = string.Format("{0};{1}", opp.ID, s.IDType); lbAction.ID = string.Format("lnkBtn{0}{1}", opp.ID, s.IDType); pnl.Controls.Add(lbAction); pnl.Controls.Add(new Label() { Text = "<br />" }); } ); }<telerik:RadGrid ID="radGridListTypeRoom" runat="server" AllowPaging="false" Width="100%" AutoGenerateColumns="false" OnDetailTableDataBind="radGridListTypeRoom_DetailTableDataBind"> <MasterTableView DataKeyNames="hotelRoomTypeId" DataMember="MasterGrid" Name="TypeRoom" Width="100%"> <DetailTables> <telerik:GridTableView DataKeyNames="hotelRoomTypeId" Name="DetailPrice" Width="100%"> <Columns> <telerik:GridTemplateColumn HeaderText="Username"> <ItemTemplate> <asp:Label ID="lblName" runat="server" Text='<%# Bind("name") %>'></asp:Label> </ItemTemplate> </telerik:GridTemplateColumn> </Columns> </telerik:GridTableView></DetailTables> <Columns> <telerik:GridBoundColumn DataField="name" HeaderText="Tipo di stanza"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="isAvailable" HeaderText="Disponibilità "> </telerik:GridBoundColumn> </Columns> </MasterTableView> <PagerStyle Mode="NextPrevAndNumeric"></PagerStyle> </telerik:RadGrid>
radGridListTypeRoom.DataSource = hotel.RoomTypes; radGridListTypeRoom.DataBind();
protected void radGridListTypeRoom_DetailTableDataBind(object source, Telerik.Web.UI.GridDetailTableDataBindEventArgs e) { GridDataItem dataItem = (GridDataItem)e.DetailTableView.ParentItem; RoomType roomType = (RoomType)dataItem.DataItem; switch (e.DetailTableView.Name) { case "DetailPrice": { break; } } }
<telerik:RadRotator ID="thumbRotator" runat="server" RotatorType="Buttons" WrapFrames="false" FrameDuration="1" ScrollDirection="Up, Down" OnItemClick="thumbRotator_ItemClick" EnableEmbeddedSkins="false" Skin="FAPortalRotator" CssClass="rotatorVertical" ItemWidth="300px" ItemHeight="225px"> <ItemTemplate> <asp:Image ID="chartImage" runat="server" AlternateText="Image" ImageUrl='<%# DataBinder.Eval(Container.DataItem, "ImageURL")%>' CssClass="thumbnail" /> </ItemTemplate> <ControlButtons LeftButtonID="img_left" RightButtonID="img_right" /> </telerik:RadRotator>
function itemShowing_handler(sender, args)
{
log(sender.get_id() +
" is about to change a frame");
var rotator = $find("<%= RadRotator1.ClientID %>");
rotator.showNext(Telerik.Web.UI.RotatorScrollDirection.Right);
}
I have 2 rotator, RadRotator1 and RadRotator2. RadRotator2 has 4 items in every showing, RadRotator1 must show items of RadRotator2, one by one in the duration of itemshowing of RadRotator2. but