views:

129

answers:

1

I would like to display clickable news headlines. But I'm having trouble pulling data from two datasources for a single GridView. I'm trying to do this DataSourceID="SqlDataSource1, SqlDataSource2" but that's not working. Thanks in advance.

<asp:GridView 
        ID="GridView1" runat="server" 
        AutoGenerateColumns="False" 
        DataSourceID="SqlDataSource1, SqlDataSource2" 
        >   
       <Columns>
           <asp:HyperLinkField  
            DataTextField = "NewsHeadline" 
            DataNavigateUrlFields="NewsURL"
          />
       </Columns>
</asp:GridView>

<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="
<%$ ConnectionStrings:ConnectionString1 %>"
       ProviderName="<%$ ConnectionStrings:ConnectionString1.ProviderName %>" 
       SelectCommand="SELECT [NewsHeadline] FROM [NewsTable]">
   </asp:SqlDataSource>

<asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="
<%$ ConnectionStrings:ConnectionString1 %>"
       ProviderName="<%$ ConnectionStrings:ConnectionString1.ProviderName %>" 
       SelectCommand="SELECT [NewsURL] FROM [NewsTable]">
</asp:SqlDataSource>
+1  A: 

A single control cannot use multiple sources.

You could create a custom data source control that accepts two data sources and produces output from both of them.

John Saunders