Home All Groups Group Topic Archive Search About

A question about Repeater control

Author
31 Jan 2006 9:20 PM
Vincent Ye
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

Author
1 Feb 2006 3:52 AM
Steven Cheng[MSFT]
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.)
Author
1 Feb 2006 4:14 AM
Vincent Ye
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

Show quoteHide quote
"Steven Cheng[MSFT]" <stch***@online.microsoft.com> wrote in message
news:m5jH0LuJGHA.3680@TK2MSFTNGXA02.phx.gbl...
> 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.)
>
>
>
>
Author
1 Feb 2006 9:01 AM
Steven Cheng[MSFT]
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.)
Author
1 Feb 2006 3:19 PM
Vincent Ye
Thanks Steven,

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

-Vincent

Show quoteHide quote
"Steven Cheng[MSFT]" <stch***@online.microsoft.com> wrote in message
news:%23na$a4wJGHA.224@TK2MSFTNGXA02.phx.gbl...
> 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.)
>
Author
2 Feb 2006 2:50 AM
Steven Cheng[MSFT]
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.)