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

mixed binding of master detail grid

1 Answer 32 Views
Grid
This is a migrated thread and some comments may be shown as answers.
andieje
Top achievements
Rank 1
andieje asked on 28 Jul 2009, 07:38 PM
Hi

Is it possible to have a master table grid whereby the master grid is bound declaratively by a data source and then the detail table is bound programmatically? I cannot get this to work.

thanks

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 29 Jul 2009, 05:02 AM
Hi,

I was able to implement the desired scenario on my end. Here is the code which I tried.

ASPX:
 
<telerik:RadGrid ID="RadGrid1" Width="800px" runat="server" Skin="Default" AutoGenerateColumns="true" ShowFooter="true" AllowPaging="true" AllowSorting="true" DataSourceID="SqlDataSource1" 
                OnDetailTableDataBind="RadGrid1_DetailTableDataBind"
                <MasterTableView DataSourceID="SqlDataSource1"  AllowFilteringByColumn="true"  > 
                     
                    <DetailTables> 
                      <telerik:GridTableView runat="server"  AutoGenerateColumns="true" > 
                           <Columns> 
                             <telerik:GridEditCommandColumn></telerik:GridEditCommandColumn> 
                           </Columns> 
                      </telerik:GridTableView> 
                    </DetailTables> 
                </MasterTableView> 
            </telerik:RadGrid> 

CS:
 
 protected void RadGrid1_DetailTableDataBind(object source, GridDetailTableDataBindEventArgs e) 
    { 
        string connectionstring = "Data Source=inc156.softinc.com; Initial Catalog=NorthWind;User ID=sa; Password=softinc"
        SqlConnection conn = new SqlConnection(connectionstring); 
 
        conn.Open(); 
        SqlDataAdapter adp = new SqlDataAdapter("SELECT ProductName,ProductID,SupplierID, Discontinued FROM Products", conn); 
        DataSet ds = new DataSet(); 
        adp.Fill(ds, "GridData"); 
        e.DetailTableView.DataSource = ds; 
        conn.Close(); 
    } 


Shinu

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