all groups > asp.net webcontrols > january 2006 >
You're in the

asp.net webcontrols

group:

A question about Repeater control


A question about Repeater control Vincent Ye
1/31/2006 4:20:16 PM
asp.net webcontrols:
Hi, All

Let me describe my problem:

I store some link information in an Access database. Now I want to show
these links in a table on my asp.net page. let's say there are 3 columns in
the table. I want to show one link per cell.

I tried to use Repeater control to implement it, but found out I could only
display one link per row because base on the example on MSDN about Repeater
control, every cell in a row is related to one field of the query result
from database.

Can you give me some suggestions about how I can display different link on
each cell by using Repeater control or I can use another control to do it?

Thanks in advance

-Vincent

Re: A question about Repeater control Vincent Ye
1/31/2006 11:14:46 PM
Hi Steven,

Thanks for your reply. But your examples do not fit my request. For
example#1, all links are displayed in one row. and example#2, there is only
one link per row. And what I need is 3 links per row.

Any more suggestion?

Thanks

-Vincent

[quoted text, click to view]

Re: A question about Repeater control stcheng NO[at]SPAM online.microsoft.com
2/1/2006 12:00:00 AM
Thanks for your quick response Vincent,

Well, I now got that you want make each row contains more than one cells.
Of course, one simple means is to use a table control and manually add the
rows and cells. (A bit rough:)). As far as I know, in the ASP.NET buildin
template list controls, only the DataList control provide some row/column
count and repeat direction setting like:

DataList.RepeatDirection and DataList.RepeatColumns

You can have a look at the two properties in MSDN which may helps some.
However, they still only provide simple customization and if we need
complex customizaing, maybe directly using Table control is the prefered
approach.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
RE: A question about Repeater control stcheng NO[at]SPAM online.microsoft.com
2/1/2006 12:00:00 AM
Hi Vincent,

Welcome to the ASPNET newsgroup.

From your description, you're using the ASP.NET repeater control to display
list of hyperlinks on page. Also, the links' data is retrieved from
database table and one link per data table row. Currently you're wondering
how to display them through html table element and each link item in a
table cell, correct?

If this is the case, I think you can consider use the template in repeater
control to declare the html table content. Since you're wantting to display
the link items in html table cell(not row), we need to bread each <td>
content into ItemTemplate. e.g:
=================
<asp:Repeater ID="Repeater1" runat="server">
<HeaderTemplate><table><tr></HeaderTemplate>

<ItemTemplate>
<td>
<a href="<%# xxx %>" ......><%# xxx %></a>
</td>
</ItemTemplate>

<FooterTemplate></tr></table></FooterTemplate>
</asp:Repeater>
===================

This will help display each data item in an html table
cell(<td>...</td>).And the links are displayed horizontally.

If we want to display them vertically, just change the template to divide
each Item into html row (<tr>...). e.g:

=================
<asp:Repeater ID="Repeater1" runat="server">
<HeaderTemplate><table></HeaderTemplate>

<ItemTemplate>
<tr>
<td>
<a href="<%# xxx %>" ......><%# xxx %></a>
</td>
</tr>
</ItemTemplate>

<FooterTemplate></table></FooterTemplate>
</asp:Repeater>
===================

Hope this helps.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)



Re: A question about Repeater control Vincent Ye
2/1/2006 10:19:15 AM
Thanks Steven,

I also think table control may be the only way to do that.

-Vincent

[quoted text, click to view]

Re: A question about Repeater control stcheng NO[at]SPAM online.microsoft.com
2/2/2006 12:00:00 AM
Thanks for the followup Vincent,

Please feel free to post here when there is anything else we can help.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
AddThis Social Bookmark Button