Sunset at Oak Island, North Carolina

Spider Web Woman Designs

How to make a URL clickable in an ASP.NET DataList

Create a new page in your site and name it datalist.aspx

In Design View, drag and drop the DataList Control on to the page.

Configure the DataSource and select the two fields you want to use for the hyperlink. In this tutorial, the two fields we used are Name and InfoLink.

Switch to Code View, select the ItemTemplate area and paste the following code in over it:

<ItemTemplate> <asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl='<%# Eval("InfoLink") %>' Text='<%# Eval("Name") %>'></asp:HyperLink> </ItemTemplate>

Change “SiteURL” to the name of the field in your database that contains the URL that you want to be clickable. Change “SiteName” to the name of the field in your database that contains the text you want displayed.

Save the page and switch back to Design View – you should now see one field displayed as Databound.

Preview the page in your browser.

Apologies to those who like to work strictly in the UI - if there is a way to this in the UI, I have not found it.


Back to Working with Access Databases in Microsoft Expression Web

 



Email UsWe're on Google+LinkedIn ProfileFollow us on TwitterLike Us on Facebook!