Display simple list

T

timmso

I am trying to build a simple asp.net project. What sort of control do I
need to use to simply display a list of links in a table format? For
example, let's say I have a database table:

tblNames
ID Name
1 Blue
2 Grey
3 Green

And I want to display these in the format of the web page:

Blue
Grey
Green

so that I can keep on adding names to the table and the page refresh will be
able to handle any new names. Then, if you click on a link, you go to the
appropriate page using ID as the identifier.

How can I do this? What control do I use for this. Can somebody please give
me some sample code or other guidance of how I "bind" this to a control in
clickable format?

Thanks.
 
M

Mike Moore [MSFT]

Hi,

I think a repeater will do what you want. Here's the HTML from a repeater I
setup to allow programmatically setting the href and viewable text. Then
you just need to setup a datasource and bind the repeater. I also included
syntax for DataBinder.Eval and the more efficient Container object.

<asp:Repeater id="Repeater1" runat="server">
<ItemTemplate>
<asp:HyperLink id="HyperLink1" runat="server" NavigateUrl='<%#
"http://localhost/ngrid1/repeater.aspx?a=" & Container.DataItem("au_lname")
%>'>'<%# DataBinder.Eval(Container.DataItem, "au_fname")%>'</asp:HyperLink>
<br>
</ItemTemplate>
</asp:Repeater>


Thank you, Mike
Microsoft, ASP.NET Support Professional

Microsoft highly recommends to all of our customers that they visit the
http://www.microsoft.com/protect site and perform the three straightforward
steps listed to improve your computer’s security.

This posting is provided "AS IS", with no warranties, and confers no rights.


--------------------
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top