Getting an URL from an Access db and turning into <a href> link

  • Thread starter Thread starter JEFF
  • Start date Start date
J

JEFF

Hello,

I am trying to get a URL out of an Access database and make it a link on an
aspx web page. For some reason it looks like this on the page:

#http://mydomain.org#

I have the following AccessDataSource

<asp:AccessDataSource ID="AccessDataSource1" runat="server"
DataFile="~/App_Data/mydata.mdb"
SelectCommand="SELECT * FROM [Events] WHERE ([ID] = ?) ORDER BY
[starttime]">
<SelectParameters>
<asp:QueryStringParameter Name="ID" QueryStringField="id"
Type="Int32" />
</SelectParameters>
</asp:AccessDataSource>

Here is myFormView item template that contains:

<asp:FormView ID="FormView1" runat="server" DataKeyNames="ID"
DataSourceID="AccessDataSource1">
<ItemTemplate>
<h2><asp:Label ID="titleLabel" runat="server" Text='<%#
Bind("title") %>'></asp:Label></h2><br />
<h3>Description: <asp:Label ID="descriptionLabel" runat="server"
Text='<%# Bind("description") %>'></asp:Label>
</h3><br />
Start Date: <asp:Label ID="starttimeLabel" runat="server"
Text='<%# Bind("starttime","{0:D}") %>'></asp:Label><br />
End Date: <asp:Label ID="endtimeLabel" runat="server"
Text='<%# Bind("endtime","{0:D}") %>'></asp:Label><br />
URL: <asp:Label ID="staticurlLabel" runat="server" Text='<%#
Bind("staticurl") %>'></asp:Label><br />
Location: <asp:Label ID="LocationLabel" runat="server"
Text='<%# Bind("Location") %>'></asp:Label><br />
Image: <asp:Label ID="ImageLabel" runat="server" Text='<%#
Bind("Image") %>'></asp:Label><br />
</ItemTemplate>
</asp:FormView>

Do I have to get the value in some sort of script and then build my own <a
href> link? How can I parse off the # chars?

Thanks in advance!
Jeff
 
Just use the HyperLink control and do the same thing you did with all your
Label controls. Databinding can be used for most controls and properties,
and I know that it can be used for the NavigateUrl property of the HyperLink
control (I have done exactly that before, and I was also using Access). If
it is putting the value inside #'s like you said, doublecheck your syntax
and the value in the database. Your code for the Text properties of the
Labels looks correct, so if you do the same thing for the NavigateUrl
property of the HyperLink you should be good.
 
Back
Top