Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Prefix the Hyperlink on a Bulleted List 1

Status
Not open for further replies.

djs45uk

Technical User
Nov 7, 2004
103
GB
Good Afternoon

I am using the following code to create a bulleted list based on records retrieved from a database. My bulleted list is set to DisplayMode="Hyperlink".

The DataTextField="downloadTitle" and the DataValueField="downloadFilename".

However, I would like to prefix the DataValueField with a string like this "download/".

Code:
<asp:BulletedList ID="releteddownloads" runat="server" DataSourceID="ds_relateddownloads"
DataTextField="downloadTitle" DataValueField="downloadFilename" DisplayMode="HyperLink">
</asp:BulletedList>
<asp:SqlDataSource ID="ds_relateddownloads" runat="server" ConnectionString="<%$ ConnectionStrings:StPaulsDatabase %>"
SelectCommand="SELECT [downloadTitle], [downloadFilename] FROM [Downloads] WHERE ([downloadCategory] = @downloadCategory)">
<SelectParameters>
<asp:Parameter DefaultValue="Laptop Scheme" Name="downloadCategory" Type="String" />
</SelectParameters>
</asp:SqlDataSource>

How can I prefix the DataValueField with a bit of text?

Many thanks

Daniel
 
one way:
SelectCommand="SELECT [downloadTitle], 'download/'+[downloadFilename] FROM [Downloads] WHERE ([downloadCategory] = @downloadCategory)">

Known is handfull, Unknown is worldfull
 
I guess whilst I'm here, does anyone know if it's possible to set the hyperlink's target also (let's say to _blank).

Many thanks in advance

Daniel
 
use this property:
Target="_blank"

Known is handfull, Unknown is worldfull
 
Thank you vbkris - I tried the following but it doesn't work.
Code:
<asp:BulletedList ID="releteddownloads" runat="server" DataSourceID="ds_relateddownloads"
DataTextField="downloadTitle" DataValueField="downloadFilename" DisplayMode="HyperLink">
</asp:BulletedList>
<asp:SqlDataSource ID="ds_relateddownloads" runat="server" ConnectionString="<%$ ConnectionStrings:StPaulsDatabase %>"
SelectCommand="SELECT [downloadTitle], 'download/'+[downloadFilename] FROM [Downloads] WHERE ([downloadCategory] = @downloadCategory)"> 
<SelectParameters>
<asp:Parameter DefaultValue="Laptop Scheme" Name="downloadCategory" Type="String" />
</SelectParameters>
</asp:SqlDataSource>
The following error is returned:
DataBinding: 'System.Data.DataRowView' does not contain a property with the name 'downloadFilename'.
 
oops:

change
'download/'+[downloadFilename]

to
'download/'+[downloadFilename] [downloadFilename]

Known is handfull, Unknown is worldfull
 
Thank you very very much! I am truly grateful.

Daniel
 
welcome...

Known is handfull, Unknown is worldfull
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top