This is a migrated thread and some comments may be shown as answers.

retrieve DataItem in DetailTableDataBind

2 Answers 188 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Giacomo Paolo
Top achievements
Rank 1
Giacomo Paolo asked on 29 Jul 2011, 02:42 PM
hi,

Hello, after populated the grid with a class

<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();

when fired the event to view the detail (Hierarchy)  how can i retrieve the object class?

        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;
                    }
            }
        }


why dataitem.dataitem is null ?

Thanks for the collaboration and sorry for bad eng.

2 Answers, 1 is accepted

Sort by
0
Giacomo Paolo
Top achievements
Rank 1
answered on 01 Aug 2011, 08:09 AM
no answer?
is a bug? or my fault?

please answer me
0
Pavlina
Telerik team
answered on 03 Aug 2011, 06:23 PM
Hi Giacomo Paolo,

Please refer tp the online example below for more information about how to achieve your goal:
http://demos.telerik.com/aspnet-ajax/grid/examples/programming/detailtabledatabind/defaultcs.aspx (see the DetailTableDataBind handler)

Kind regards,
Pavlina
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

Tags
Grid
Asked by
Giacomo Paolo
Top achievements
Rank 1
Answers by
Giacomo Paolo
Top achievements
Rank 1
Pavlina
Telerik team
Share this question
or