Bulletedlist - Databound - Hyperlink

H

Håkan

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
 
D

David Longnecker

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.
 

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,774
Messages
2,569,596
Members
45,139
Latest member
JamaalCald
Top