473,386 Members | 1,694 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Help with a Repeater Issue

GD
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

Nov 19 '05 #1
2 1898
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

Nov 19 '05 #2
GD
Thanks Joshua!
I'll give that a shot

Nov 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Invalidlastname | last post by:
Hi, We are developing an asp.net application, and we dynamically created certain literal controls to represent some read-only text for certain editable controls. However, recently we found an issue...
1
by: MattB | last post by:
OK, never mind my last post. It was easy enough to refer to the table the repeater is bound to, but I made a big, incorrect assumption in that post. In my last post I thought I was successfully...
0
by: MattB | last post by:
I fixed my "can't get the textbox.text" issue by making sure I was only binding the repeater on the first load of the page (if Not IsPostBack). Now I'm adding other controls to my repeater and am...
4
by: Ryan Ternier | last post by:
Hello, I have a repeater control that does the following on the ItemDataBound event. It works perfectly, except that when it prints out, the names of the controls aren't what I'd expect. ...
8
by: Matthew Curiale | last post by:
I am creating an app that lists clients of a company for management of different attributes for that company. The first page is a listing of the companies currently in the database. I have my...
1
by: Ryan Ternier | last post by:
I'm having the issue is when I re-bind my repeater to show the changes done to it from the code behind. I'm binding this repeater from a DataTable that is stored in the ViewState for now. It...
7
by: | last post by:
I have what's probably a simple page lifecycle question related to dynamically evaluating values that are placed by a repeater and dynmically placing user controls that use those values. I'm...
4
by: Mick Walker | last post by:
I am using a repeater to display contacts to the user. Here is my repeater: <asp:Repeater ID="RepContacts" runat="server"> <HeaderTemplate><table cellpadding="5" cellspacing="2"> <tr>...
3
by: Queez | last post by:
I have an issue with an ASP repeater which is seriously frustrating me. In simple terms, I have an ASP repeater which is meant to display a list of items for a wedding list, including the name of...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.