Hi,
What is the best way to bind a detailtable with the same record as the master?
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!
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!