Problem with 2 SqlDataSource

J

Julien Sobrier

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
Julien
 
M

Masudur

Hi...
.........
-> <asp:SqlDataSource ID="SqlStructure" runat="server"

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


Thanks
Masudur
 
J

Julien Sobrier

Masudur said:
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" /

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


Thanks
Masudur


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>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,226
Members
46,815
Latest member
treekmostly22

Latest Threads

Top