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

DetailTable that shows the same record as the master

1 Answer 28 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Mattias
Top achievements
Rank 1
Mattias asked on 30 Jan 2009, 11:02 AM
Hi,
What is the best way to bind a detailtable with the same record as the master?

    <telerik:radgrid  
        ID="radGridBusinessRegister"  
        runat="server"  
        allowpaging="True"  
        allowsorting="True"  
        gridlines="None"  
        onneeddatasource="radGridBusinessRegisterNeedDataSource" 
        OnDetailTableDataBind="radGridBusinessRegisterDetailTableDataBind" 
        Skin="SkyBlue" 
        ShowGroupPanel="false" 
        AutoGenerateColumns="false"
        <MasterTableView  
            DataKeyNames="ID"  
            Name="Master"
            <Columns> 
                <telerik:GridBoundColumn UniqueName="Name" DataField="Name" HeaderText="Namn" /> 
                <telerik:GridBoundColumn UniqueName="Phone1" DataField="Phone1" HeaderText="Telefon" /> 
                <telerik:GridBoundColumn UniqueName="Email" DataField="Email" HeaderText="E-post" /> 
            </Columns> 
            <DetailTables> 
                <telerik:GridTableView 
                    DataKeyNames="ID" 
                    AutoGenerateColumns="true" 
                    ShowHeader="false" 
                    Name="Detail" 
                    CommandItemDisplay="None"
                    <ItemTemplate> 
                        <h1>Detaljsida för <%# Eval("Name") %></h1
                        <p><%# Eval("Description") %></p
                    </ItemTemplate> 
                </telerik:GridTableView> 
            </DetailTables> 
        </MasterTableView> 
    </telerik:radgrid> 

protected void radGridBusinessRegisterDetailTableDataBind(object source, GridDetailTableDataBindEventArgs e) 
        { 
            if (e.DetailTableView.Name == "Detail"
            { 
                int id = (int)e.DetailTableView.ParentItem.GetDataKeyValue("ID"); 
                e.DetailTableView.DataSource = CompanyService.GetById(id); 
            } 
        } 

This is not working because the datasource needs a different kind of data type.
Error: Data source is an invalid type.  It must be either an IListSource, IEnumerable, or IDataSource.

I guess I don't need the round trip to the database either!

1 Answer, 1 is accepted

Sort by
0
Mattias
Top achievements
Rank 1
answered on 30 Jan 2009, 01:57 PM
HA! It was to simple! :)
I don't need to bind at all! The detail table inherits automatically the master table.

Telerik, you're the best! :)

Hmm, it would be nice to be able to mark my own reply as final answer!
Tags
Grid
Asked by
Mattias
Top achievements
Rank 1
Answers by
Mattias
Top achievements
Rank 1
Share this question
or