Re: Repeater Control : Can it work with different data sources?



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 <table> and all header tags
<th>something</th> in 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.middlebrook@xxxxxxxxxxxxxx> wrote in message
news:1194370093.945599.69720@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
On 6 Nov, 13:37, "Cowboy \(Gregory A. Beamer\)"
<NoSpamMgbwo...@xxxxxxxxxxxxxxxxxx> wrote:
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...@xxxxxxxxxxxxxx> wrote in message

news:1194348979.858186.137940@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

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



.



Relevant Pages

  • Re: how do i only number pages if there is more than 1 page
    ... Your document should be set up with a Different First Page Header as Jay ... header on the same template I have an image which I designed on Publisher ... in the second page footer, ... If I folllow your first suggestion below then every page would have ...
    (microsoft.public.word.vba.general)
  • Re: Creating document template with unique requirements
    ... "Template Challenge" wrote in message ... > 1 has a 2" top margin with no header, and the footer ... > margin with a header that reads "Quarterly News Release" ...
    (microsoft.public.word.formatting.longdocs)
  • Re: How to fill header, body and footer using VBA?
    ... formatted with a custom header and footer. ... I expect that the vba will read in a static template that is a mail merge ...
    (microsoft.public.word.vba.general)
  • Re: Modifing the Header and Footer content
    ... that after saving the template .dot file when I double click on the template ... refreshes the Header and Footer area and that is great but sometimes I create ... Dim MedHist As Document ...
    (microsoft.public.word.vba.general)
  • Re: How to fill header, body and footer using VBA?
    ... formatted with a custom header and footer. ... I expect that the vba will read in a static template that is a mail merge ...
    (microsoft.public.office.developer.vba)

Loading