'use two DataSource for one Repeater
I have two tables in the SQL server the first:
ID , Journal, ScoreB
1 aa 10.2
2 bb 3.4
3 cc 4.9
and the second table :
ID , Journal , ScoreA
1 aa 4
2 ff 3.5
4 ss 3.8
The two tables contain the journals and rank them in scoreA and ScoreB, some journals are in the two tables but have a different rank based on the type (scoreA or ScoreB).
I put button A and button b, when clicking A the repeater display table A and when click button b the same repeater display table B.
How can I do that? display tow table in the same repeater and also change table header (SorceA) to (SourceB) when clicked button B
UPDATE :
below the repeater code
<asp:Repeater ID="Journals1" runat="server" EnableViewState="true">
<ItemTemplate>
<tbody>
<tr class="odd views-row-first">
<td class="views-field views-field-title" > <%# Eval("Journal") %> </td>
<td class="views-field views-field-title"> <%# Eval("ScoreB") %> </td>
<td class="views-field views-field-title"> <%# Eval("ScoreA") %> </td>
</tr>
</tbody>
</ItemTemplate>
</asp:Repeater>
when the user Click buttonA the repeater display this query (SELECT * FROM JournalA ) and when click buttonB the repeater display this query (SELECT * FROM JournalB ) at the same repeater. the problem in (Eval("ScoreB") ) the first query does not contain ScoreB So the repeater show error.
Solution 1:[1]
Probably better to use a query to merge the two sets like this:
SELECT Journal, ScoreA,
(SELECT scoreB from ScoreB where ScoreB.Journal = ScoreA.Journal) as ScoreB
FROM scoreA
union all
SELECT Journal, ScoreB,
(SELECT scoreA from scoreA where ScoreA.Journal = ScoreB.Journal) as ScoreA
FROM ScoreB
WHERE not exists(select scoreA from scoreA where scoreA.Journal = ScoreB.Journal)
So then you only have to feed the repeater one query.
The result of the above query would thus look like this
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Albert D. Kallal |

