Groups | Blog | Home
all groups > asp.net > august 2007 >

asp.net : Problem with 2 SqlDataSource



Julien Sobrier
8/17/2007 10:31:21 PM
Hello,
I have 2 SqlDataSource on the same page that retrieve the same column names:

<asp:SqlDataSource ID="SqlStructure" runat="server"
SelectCommand="SELECT a, b FROM c WHERE d = 0 />

<asp:SqlDataSource ID="SqlSons" runat="server"
SelectCommand="SELECT a, b FROM c WHERE d = 74" />

The problem is that Eval("a") always return the value from SqlStructure.
I tried to change the query to "SELECT a AS x, b AS Y FROM c WHERE d =
74" but Eval("Y") returns an error.

The ultimate goal is to have something like this:

<asp:SqlDataSource ID="SqlStructure" runat="server"
SelectCommand="SELECT a, b FROM c WHERE d = 0 />

<asp:Repeater ID="Repeater1" runat="server" DataSourceID="SqlStructure" />
<ItemTemplate>
<h2><%# Eval("b")%></h2>

<asp:SqlDataSource ID="SqlStructure" runat="server"
SelectCommand="SELECT a AS X, b AS Y FROM c WHERE d = <%#
Eval('a') %> />

<asp:Repeater ID="Repeater2" runat="server" DataSourceID="SqlSons" />
<ItemTemplate>
<p><%# Eval("b AS Y")%></p>
<ItemTemplate>
</asp:Repeater>
</ItemTemplate>
</asp:Repeater>


Thank you
Masudur
8/18/2007 12:00:00 AM
Hi...
.........
-> <asp:SqlDataSource ID="SqlStructure" runat="server"
SelectCommand="SELECT a AS X, b AS Y FROM c WHERE d = <%# Eva('a') />
-> <asp:Repeater ID="Repeater2" runat="server" DataSourceID="SqlSons" /
[quoted text, click to view]

why the datasource id of the inner repeater is sqlSons... and in
sqldatasource it is said SqlStructure ?


Thanks
Masudur
Julien Sobrier
8/18/2007 9:07:21 AM
[quoted text, click to view]


I have 2 SqlDataSource (SqlStructure and SqlSons) which are both used:

<asp:SqlDataSource ID="SqlStructure" runat="server"
SelectCommand="SELECT a, b FROM c WHERE d = 0 />

<asp:SqlDataSource ID="SqlSons" runat="server"
SelectCommand="SELECT a, b FROM c WHERE d = 74" />

The problem is that Eval("a") always return the value from SqlStructure.
I tried to change the query to "SELECT a AS x, b AS Y FROM c WHERE d =
74" but Eval("Y") returns an error.

The ultimate goal is to have something like this:

<asp:SqlDataSource ID="SqlStructure" runat="server"
SelectCommand="SELECT a, b FROM c WHERE d = 0 />

<asp:Repeater ID="Repeater1" runat="server" DataSourceID="SqlStructure" />
<ItemTemplate>
<h2><%# Eval("b")%></h2>

<asp:SqlDataSource ID="SqlStructure" runat="server"
SelectCommand="SELECT a AS X, b AS Y FROM c WHERE d = <%#
Eval('a') %> />

<asp:Repeater ID="Repeater2" runat="server" DataSourceID="SqlSons" />
<ItemTemplate>
<p><%# Eval("b AS Y")%></p>
<ItemTemplate>
</asp:Repeater>
</ItemTemplate>
</asp:Repeater>

AddThis Social Bookmark Button