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

Can you use <#%Eval fieldname%> with 2 datasources

1 Answer 236 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Brett
Top achievements
Rank 1
Brett asked on 27 Jul 2009, 07:24 PM
Is it possible to have more then one datasource with the <#%Eval fieldname%> literal?  I am using sql data source for a radgrid and I want to use another sql data source for a sub section underneath the radgrid in a lower hierarchy.

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 28 Jul 2009, 06:46 AM
Hi Brett,

I guess you are having a hierarchical Grid where you are setting the master and detail table to two different SqlDataSources. And you have got  the same field name in both the DataSources. If this is the case i dont think there will be any problem in  binding the Grid columns of the master and Detail table to the same filed name. But you may set different UniqueNames for both the columns.

Here is the sample aspx code which I tried on my  end.

ASPX:
 
 
  
<telerik:RadGrid ID="RadGrid2" runat="server" ShowHeader="true" AllowSorting="true" AllowFilteringByColumn="true"     AllowPaging="true" PageSize="5"  DataSourceID="SqlDataSource1" > 
<MasterTableView AutoGenerateColumns="False"  CommandItemDisplay="top" 
                    DataSourceID="SqlDataSource1"
                <Columns> 
                  
                      <telerik:GridTemplateColumn UniqueName="ProductID1" HeaderText="ProductID" > 
                                <ItemTemplate> 
                                    <asp:Literal ID="Literal1" runat="server"  Text='<%#Eval("ProductID") %>'  ></asp:Literal> 
                                </ItemTemplate> 
                            </telerik:GridTemplateColumn> 
                    
                </Columns> 
                <DetailTables> 
                    <telerik:GridTableView runat="server" Caption="Detail"  Name="Detail" CommandItemDisplay="top" 
                        DataSourceID="SqlDataSource2" > 
                         
                        <Columns> 
                            
                            <telerik:GridTemplateColumn UniqueName="ProductID2" HeaderText="ProductID" > 
                                <ItemTemplate> 
                                    <asp:Literal ID="Literal2" runat="server"  Text='<%#Eval("ProductID") %>'  ></asp:Literal> 
                                </ItemTemplate> 
                            </telerik:GridTemplateColumn> 
                          
                        </Columns> 
                    </telerik:GridTableView> 
                </DetailTables> 
                 
            </MasterTableView> 
 
</telerik:RadGrid> 
 
 
  <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:NorthWindConnectionString %>" 
            SelectCommand="SELECT [ProductID], [ProductName], [SupplierID],[Discontinued],[StarDate] FROM [Products]"
        </asp:SqlDataSource> 
    
        <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:NorthWindConnectionString %>" 
            SelectCommand="SELECT [OrderID], [ProductID] FROM [Orders]"></asp:SqlDataSource> 
 


Princy
Tags
General Discussions
Asked by
Brett
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or