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

Grid DetailsTable bound columns

2 Answers 79 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Graham
Top achievements
Rank 1
Graham asked on 19 Mar 2014, 09:54 AM
hello

Just trialling UI for ASP.NET and wanted to check this is correct (apologies if obvious, first time user of Telerik controls).

I add a datasource to  grid and the columns appear automatically and I can format etc

When I add a DetailTable the columns from the datasource appear when I run in the browser, but if I want to format I need to go into the 'Columns' section and Add Bound columns and add the DataField property for each column

I would have through the columns would appear automatically (Available Columns) for the detail in the same way they appear for the MasterTableView

thanks

Graham

2 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 19 Mar 2014, 10:14 AM
Hi Graham,

Please have a look at the sample code snippet below. Provide your code snippet if this doesn't help and elaborate on your requirement.

ASPX:
<telerik:RadGrid ID="RadGrid1" runat="server" DataSourceID="SqlDataSource1" AllowFilteringByColumn="True" AllowPaging="True" AllowSorting="True">
    <MasterTableView DataKeyNames="CustomerID">
        <HeaderStyle ForeColor="Red" />
        <DetailTables>
            <telerik:GridTableView Name="Orders" runat="server" DataKeyNames="OrderID" DataSourceID="SqlDataSource2">
                <HeaderStyle ForeColor="Blue" HorizontalAlign="Center" />
                <ItemStyle ForeColor="Green" />
                <AlternatingItemStyle ForeColor="Orange" />
                <ParentTableRelation>
                    <telerik:GridRelationFields DetailKeyField="CustomerID" MasterKeyField="CustomerID" />
                </ParentTableRelation>
            </telerik:GridTableView>
        </DetailTables>
    </MasterTableView>
</telerik:RadGrid>
<asp:SqlDataSource ID="SqlDataSource1" ConnectionString="<%$ ConnectionStrings:Northwind_newConnectionString3 %>" ProviderName="System.Data.SqlClient" SelectCommand="SELECT CustomerID,CompanyName,ContactName,ContactTitle,Address FROM Customers"
    runat="server"></asp:SqlDataSource>
<asp:SqlDataSource ID="SqlDataSource2" ConnectionString="<%$ ConnectionStrings:Northwind_newConnectionString3 %>"
    ProviderName="System.Data.SqlClient" SelectCommand="SELECT OrderID,ShipCity,EmployeeID,OrderDate FROM Orders Where CustomerID = @CustomerID"
    runat="server">
    <SelectParameters>
        <asp:SessionParameter Name="CustomerID" SessionField="CustomerID" Type="string">
        </asp:SessionParameter>
    </SelectParameters>
</asp:SqlDataSource>

Thanks,
Shinu
0
Graham
Top achievements
Rank 1
answered on 20 Mar 2014, 06:50 AM
thanks Shinu, I have my solution all working even though I need to manually add the bound columns to the Details Table. I will leave it for tor the moment. interestingly the DataKey Names drop down does show all the columns from the datasource

Tags
Grid
Asked by
Graham
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Graham
Top achievements
Rank 1
Share this question
or