Click to See Complete Forum and Search --> : Using templates with custom repeater control


bmonchka
11-03-2006, 02:25 PM
Hi. I want to create my own repeater control. I am not sure how to use templates with it (header, body, footer). How do I find the html and databinding expressions that are between the opening (<itemTemplate>) and closing (</itemTemplate>) xml tags and only repeat that portion of html and print the header and footer templates only once. If anyone has any sample VB code on how to do this or is able to explain this I would really appreciate it.

thanks so much,
Barret

Phil Weber
11-03-2006, 02:40 PM
See if these help:
http://samples.gotdotnet.com/quickstart/aspplus/doc/webctrlauthoring.aspx#templated
http://msdn.microsoft.com/msdnmag/issues/05/06/CuttingEdge/

bmonchka
11-03-2006, 03:35 PM
Thank you for your reply but that is not exactly what I am looking for.

I want to create a custom databound control to display search results of
products from an online store's database. I want to display a ceratain
amount of products per page and allow the user to be able to skip to
different pages, next page, prev page, display number of results etc.
So I want to use a for loop to print out the resulting products and stop the
loop when the incrementer hits a certain number and start the incrementer at
different numbers depending on what page the user is on.
That's easy enought to do, I could do that. However, I don't want any
of my html in my custom databound control. I want the custom databound
control's for loop to print out the values for the databinding expressions
<% Eval("whatever object property") %> within the template.

for ex:

<emptyResultSet>

Your search did not produce any results.....

</emptyResultSet>

<searchResult>

<table>
<tr>
<td>
<span style="whatever"><% Eval("ProductName") %></span>
<div style="whatever">< Eval("ProductPrice") %></span>
</td>
</tr>
</table>

</searchResult>

<resultSetInfo>

<table><tr><td>Next, Prev, First, Last (How many results)</td></tr></table>

</resultSetInfo>

I above html does not make any sense it is just an example. So, I don't
know how (from within the control) to get the html from the
<searchResult> opening and closing xml template tags and print that in
the for loop while evaluating the databinding expressions.


I hope you could help, thank you so much,

Barret