Hi GD,
You have two loops...one for each line of the report (call it loopLine), and
the other for each column in the report (call it loopColumn). You can
implement this any number of ways, but probably the cleanest way is to use
two repeaters, one for each line of the report, and the other for each
column in the report.
As far as data binding goes, you don't have to use DataBinder.Eval. If your
rptCompanies data source was an array of lines, and your rptColumns data
source was an array of column names (including the name of the company), you
can just bind each repeater to a string array, as follows (pseudo-code):
<asp:Repeater ID="rptCompanies" runat="server"
OnItemDataBound="rptCompanies_ItemDataBound">
<ItemTemplate>
<asp:Repeater ID="rptColumns" runat="server">
<ItemTemplate>
<td><%# (string)Container.DataItem %></td>
</ItemTemplate>
</asp:Repeater>
</ItemTemplate>
</asp:Repeater>
protected void Page_Load(object sender, EventArgs e)
{
string totalReport = "Company1,1,2,3\nCompany2,3,4,5\nCompany3,6,7, 8"; //
this is the big report data
string[] lines = totalReport.Split('\n');
rptCompanies.DataSource = lines;
rptCompanies.DataBind();
}
protected void rptCompanies_ItemDataBound(object sender,
RepeaterItemEventArgs e)
{
string line = (string)e.Item.DataItem; // Assuming the data is a string
(as above)
string[] cols = line.Split(',');
Repeater rptColumns = (Repeater)e.Item.FindControl("rptColumns");
rptColumns.DataSource = cols;
rptColumns.DataBind();
}
--
Joshua Mitts
jo****@msn.com
"GD" <ge**********@gmail.com> wrote in message
news:11*********************@g47g2000cwa.googlegro ups.com...
I'd like to use a Repeater to display data coming back from a cross-tab
report. Because it's a cross-tab, I generally don't know how many
columns are coming back. They do follow a certain format:
e.g. CompanyName, c1, c2, c3, etc ..
The current format of my repeater is:
<table>
<asp:Repeater ID="rptCompanies" Runat="server">
<ItemTemplate>
<tr class="Company">
<td><%# DataBinder.Eval(Container.DataItem, "CompanyName") %></td>
</tr>
</ItemTemplate>
</asp:Repeater>
</table>
what I would need is something like:
<table>
<asp:Repeater ID="rptCompanies" Runat="server">
<ItemTemplate>
<tr class="Company">
<td><%# DataBinder.Eval(Container.DataItem, "CompanyName") %></td>
<td><%# DataBinder.Eval(Container.DataItem, "c1") %></td>
<td><%# DataBinder.Eval(Container.DataItem, "c2") %></td>
<td><%# DataBinder.Eval(Container.DataItem, "c3") %></td>
</tr>
</ItemTemplate>
</asp:Repeater>
</table>
But since I don't know how many columns I have coming back, I can't
specify them in the repeater. How can I accomplish this? A nested
repeater?
P.S. I know this can be easily done using a DataGrid, if there's not a
good way to accomplish it using a Repeater, I'll go in that direction.
Thanks