473,327 Members | 2,081 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,327 software developers and data experts.

Repeater Control : Can it work with different data sources?

Hi there,

I've been trying to implement a repeater control in an ASP.NET 2 page
but I can't seem to get the layout exactly how I want and I'm not sure
if it's something that I am doing wrong or maybe the repeater control
doesn't have the capabilities...?

The page needs to display a custom number of sections that appear the
same but have different data..

E.g. Like a bank statement..

Label: Transactions for date ....

A table showing the transactions.

Then ideally a row at the bottom totalling the columns in the grid.

I've implemented a repeater control putting the first label in the
header, then the item template holds all the transactions. The total
row was put in the footer template..

Unfortunately, I can only see a way to have one block. This needs to
be dynamic as I'm told at display time how many blocks of transactions
I need to output onto the page...

Here's the aspx code I've come up with so far...

<asp:Repeater ID="siteSummary" runat="server"
DataSourceID="sitesDS" OnItemDataBound="ItemBound">
<HeaderTemplate>
<table width="100%">
<tr>
<asp:Label ID="itemHeader" width="100%"
BackColor="#C25E00" ForeColor="White" Text="Transactions"
runat="server"/>
</tr>
<tr>
<th>Description</th>
<th>Total</th>
</tr>
</HeaderTemplate>

<ItemTemplate>
<tr>
<td><%#DataBinder.Eval(Container.DataItem,
"Description").ToString()%></td>
<td><%#DataBinder.Eval(Container.DataItem,
"Total").ToString()%></td>
</tr>
</ItemTemplate>

<FooterTemplate>
<tr>
<td></td>
<td>Todo: total?</td>
</tr>
</table>
</FooterTemplate>
</asp:Repeater>

Perhaps there is a better way of doing this that I am not familiar
with?

Many thanks,

Emma

Nov 6 '07 #1
3 3918
The main body of the Repeater repeats for every row in your result set. And,
as you control the HTML, you do not have to attempt to bind multiple
recordsets to a single Repeater to get header and footer, as you can create
the table header and footer outside of the Repeater.

Does this answer your concern?

--
Gregory A. Beamer
MVP, MCP: +I, SE, SD, DBA

*************************************************
| Think outside the box!
|
*************************************************
"Emma Middlebrook" <e.***********@googlemail.comwrote in message
news:11**********************@o38g2000hse.googlegr oups.com...
Hi there,

I've been trying to implement a repeater control in an ASP.NET 2 page
but I can't seem to get the layout exactly how I want and I'm not sure
if it's something that I am doing wrong or maybe the repeater control
doesn't have the capabilities...?

The page needs to display a custom number of sections that appear the
same but have different data..

E.g. Like a bank statement..

Label: Transactions for date ....

A table showing the transactions.

Then ideally a row at the bottom totalling the columns in the grid.

I've implemented a repeater control putting the first label in the
header, then the item template holds all the transactions. The total
row was put in the footer template..

Unfortunately, I can only see a way to have one block. This needs to
be dynamic as I'm told at display time how many blocks of transactions
I need to output onto the page...

Here's the aspx code I've come up with so far...

<asp:Repeater ID="siteSummary" runat="server"
DataSourceID="sitesDS" OnItemDataBound="ItemBound">
<HeaderTemplate>
<table width="100%">
<tr>
<asp:Label ID="itemHeader" width="100%"
BackColor="#C25E00" ForeColor="White" Text="Transactions"
runat="server"/>
</tr>
<tr>
<th>Description</th>
<th>Total</th>
</tr>
</HeaderTemplate>

<ItemTemplate>
<tr>
<td><%#DataBinder.Eval(Container.DataItem,
"Description").ToString()%></td>
<td><%#DataBinder.Eval(Container.DataItem,
"Total").ToString()%></td>
</tr>
</ItemTemplate>

<FooterTemplate>
<tr>
<td></td>
<td>Todo: total?</td>
</tr>
</table>
</FooterTemplate>
</asp:Repeater>

Perhaps there is a better way of doing this that I am not familiar
with?

Many thanks,

Emma

Nov 6 '07 #2
On 6 Nov, 13:37, "Cowboy \(Gregory A. Beamer\)"
<NoSpamMgbwo...@comcast.netNoSpamMwrote:
The main body of the Repeater repeats for every row in your result set. And,
as you control the HTML, you do not have to attempt to bind multiple
recordsets to a single Repeater to get header and footer, as you can create
the table header and footer outside of the Repeater.

Does this answer your concern?

--
Gregory A. Beamer
MVP, MCP: +I, SE, SD, DBA

*************************************************
| Think outside the box!
|
*************************************************" Emma Middlebrook" <e.middlebr...@googlemail.comwrote in message

news:11**********************@o38g2000hse.googlegr oups.com...
Hi there,
I've been trying to implement a repeater control in an ASP.NET 2 page
but I can't seem to get the layout exactly how I want and I'm not sure
if it's something that I am doing wrong or maybe the repeater control
doesn't have the capabilities...?
The page needs to display a custom number of sections that appear the
same but have different data..
E.g. Like a bank statement..
Label: Transactions for date ....
A table showing the transactions.
Then ideally a row at the bottom totalling the columns in the grid.
I've implemented a repeater control putting the first label in the
header, then the item template holds all the transactions. The total
row was put in the footer template..
Unfortunately, I can only see a way to have one block. This needs to
be dynamic as I'm told at display time how many blocks of transactions
I need to output onto the page...
Here's the aspx code I've come up with so far...
<asp:Repeater ID="siteSummary" runat="server"
DataSourceID="sitesDS" OnItemDataBound="ItemBound">
<HeaderTemplate>
<table width="100%">
<tr>
<asp:Label ID="itemHeader" width="100%"
BackColor="#C25E00" ForeColor="White" Text="Transactions"
runat="server"/>
</tr>
<tr>
<th>Description</th>
<th>Total</th>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td><%#DataBinder.Eval(Container.DataItem,
"Description").ToString()%></td>
<td><%#DataBinder.Eval(Container.DataItem,
"Total").ToString()%></td>
</tr>
</ItemTemplate>
<FooterTemplate>
<tr>
<td></td>
<td>Todo: total?</td>
</tr>
</table>
</FooterTemplate>
</asp:Repeater>
Perhaps there is a better way of doing this that I am not familiar
with?
Many thanks,
Emma
Hi there,

Thanks a lot, I don't think I have fully understood the header, item
and footer parts of the repeater.. I have removed the header and
footer portions...

Thanks,

Emma

Nov 6 '07 #3
The repeater, as a control, is made up of templates for rows of data (and
alternating rows, if you want to, for example, have different shading on
every second row) and then a header and footer template.

The norm, when creating a table, is to put the <tableand all header tags
<th>something</thin the header template. You then put all of the footer
information in the footer template, which may just be </table>

For every row in the bound dataset (output of DataSource control, etc.), you
get a row in the repeater that looks like the row template (or row and
alternating row templates).

If you have data for the header from one data source, for the footer from
another and for the main repeating sections from another, you are better to
move the <table><th... stuff out of the repeater and bind separately. Same
with the footer. Then, the repeater is just creating rows.

One caveat. You may have to fill the empty template (no records) in the
repeater to avoid a bad looking table. Other than that, it is a sound
method.

Does that help a bit more?

--
Gregory A. Beamer
MVP, MCP: +I, SE, SD, DBA

*************************************************
| Think outside the box!
|
*************************************************
"Emma Middlebrook" <e.***********@googlemail.comwrote in message
news:11*********************@y42g2000hsy.googlegro ups.com...
On 6 Nov, 13:37, "Cowboy \(Gregory A. Beamer\)"
<NoSpamMgbwo...@comcast.netNoSpamMwrote:
>The main body of the Repeater repeats for every row in your result set.
And,
as you control the HTML, you do not have to attempt to bind multiple
recordsets to a single Repeater to get header and footer, as you can
create
the table header and footer outside of the Repeater.

Does this answer your concern?

--
Gregory A. Beamer
MVP, MCP: +I, SE, SD, DBA

*********************************************** **
| Think outside the box!
|
************************************************* "Emma Middlebrook"
<e.middlebr...@googlemail.comwrote in message

news:11**********************@o38g2000hse.googleg roups.com...
Hi there,
I've been trying to implement a repeater control in an ASP.NET 2 page
but I can't seem to get the layout exactly how I want and I'm not sure
if it's something that I am doing wrong or maybe the repeater control
doesn't have the capabilities...?
The page needs to display a custom number of sections that appear the
same but have different data..
E.g. Like a bank statement..
Label: Transactions for date ....
A table showing the transactions.
Then ideally a row at the bottom totalling the columns in the grid.
I've implemented a repeater control putting the first label in the
header, then the item template holds all the transactions. The total
row was put in the footer template..
Unfortunately, I can only see a way to have one block. This needs to
be dynamic as I'm told at display time how many blocks of transactions
I need to output onto the page...
Here's the aspx code I've come up with so far...
<asp:Repeater ID="siteSummary" runat="server"
DataSourceID="sitesDS" OnItemDataBound="ItemBound">
<HeaderTemplate>
<table width="100%">
<tr>
<asp:Label ID="itemHeader" width="100%"
BackColor="#C25E00" ForeColor="White" Text="Transactions"
runat="server"/>
</tr>
<tr>
<th>Description</th>
<th>Total</th>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td><%#DataBinder.Eval(Container.DataItem,
"Description").ToString()%></td>
<td><%#DataBinder.Eval(Container.DataItem,
"Total").ToString()%></td>
</tr>
</ItemTemplate>
<FooterTemplate>
<tr>
<td></td>
<td>Todo: total?</td>
</tr>
</table>
</FooterTemplate>
</asp:Repeater>
Perhaps there is a better way of doing this that I am not familiar
with?
Many thanks,
Emma

Hi there,

Thanks a lot, I don't think I have fully understood the header, item
and footer parts of the repeater.. I have removed the header and
footer portions...

Thanks,

Emma

Nov 6 '07 #4

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

Similar topics

3
by: anon | last post by:
I am having a hard time with makeing what I am trying to do work. I am making a questionaire web app. I have a custom control that has a label and 5 radio buttons. My problem is that each...
4
by: MattB | last post by:
This is just a rephrased version of a question I posted earlier. I think I'm closer now, so it seemed worthy of a new (more specific) post. In my repeater I'm dynamically creating text boxes, so...
3
by: WebMatrix | last post by:
I am struggling with implementing somewhat complicated UI web-control. I explored Repeater, but I am not sure if it's the best way to go. I am leaning towards writing my own custom control and...
7
by: charliewest | last post by:
Hello - I'm using a Repeater control to render information in a very customized grid-like table. The Repeater control is binded to a DataSet with several records of information. Within the...
3
by: Andrew | last post by:
Hi, I am working on a questionnaire. I have displayed a questionnaire using a repeater control. The itemtemplate is as below (quite cut down): <ItemTemplate> <tr><td> <%#...
9
by: Jaybuffet | last post by:
my aspx has something like this <asp:Repeater id="Repeater1" runat="server"> <ItemTemplate> <mycontrol:ctl id="ctlId" obj='<%# Container.DataItem %>' showItem="true"/> </ItemTemplate>...
2
by: RichardH | last post by:
Hi, I have x number of table rows that all should have a checkbox and a dropdownlist on each row. The checkbox could be checked and the dropdown should contain y number of values that are...
8
by: fernandezr | last post by:
I would like to use a user control as a template inside a repeater. Some of the fields in the control should be hidden depending on whether or not there is data. I'm still a ASP .Net newbie so the...
1
by: Doogie | last post by:
Hi, I have been trying to get a checkbox added to a repeater control of mine and then try to access events of the repeater control when a user clicks the checkbox. At first, since the control is...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.