Re: Bulletedlist - Databound - Hyperlink

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



I'm not aware of a way to do this directly with the BulletedList object. I'd recommend using a repeater and a couple of helper functions for parsing out your data. You could probably place a placeHolder control and do this in codebehind a bit cleaner too.

<head runat="server">

<script runat="server">
public string generateUrl(string parameter)
{
return "~/MyPage.aspx?id=" + parameter; }

public string generateTitle(string parameter)
{
return parameter + "'s home page";
}
</script>

</head>

<body>
....
....

<ul>
<asp:Repeater ID="Repeater1" runat="server" DataSourceID="SqlDataSource1">
<ItemTemplate>
<li>
<asp:HyperLink ID="hlEntry" runat="server" NavigateUrl='<%# generateUrl(Eval("username").ToString()) %>'
Text='<%# generateTitle(Eval("username").ToString()) %>' />
</li>
</ItemTemplate>
</asp:Repeater>
</ul>

....
....

</body>

HTH.

---
David R. Longnecker
Web Developer
http://blog.tiredstudent.com

Hi!

How do you format the href field of the <a>-tag when you use a
databound BulletedList in Hyperlink mode?

The field in the database contains an ID that I want to use as a
parameter in the url for the Bulletedlists hyperlink tag.

/Håkan




.