|
-
Aug 12th, 2005, 02:55 AM
#1
Thread Starter
Hyperactive Member
Adding "HTTP://" to URL's
Hi, I'm developing a website for a company that has all their client details on an access database, this information includes a web address which is stored as "www.somebody.com".
The problem is when I use a hyperlink column in the datagrid and bind this field to it, the URL appears as "http://customers_site/www.somebody.com" instead of http://www.somebody.com. I thought it would be simple to add "http://" to the begining of the address using the following code:
Code:
<asp:Hyperlink NavigateURL="http://" & '<%# Container.DataItem("website")%>' Text="Website" runat="server" />
But this doesn't work, I'm pretty new to asp.net so any help would be appreciated, the only other optionj is to manually add http:// to every entry in the database which I want to avoid if possible
-
Aug 12th, 2005, 05:00 AM
#2
Re: Adding "HTTP://" to URL's
Let the hyperlink look like:
<asp:Hyperlink id="hylEdit" Text="Website" runat="server" />
In the datagrid's ItemDataBound event, do this:
VB Code:
If e.Item.ItemType = ListItemType.AlternatingItem Or e.Item.ItemType = ListItemType.Item Then
Dim hylD As New HyperLink
hylD = CType(e.Item.FindControl("hylEdit"), HyperLink)
hylD.NavigateUrl = "http://" & ds.Tables(0).Rows(e.Item.ItemIndex).Item("website").ToString()
End If
-
Aug 12th, 2005, 11:15 AM
#3
Thread Starter
Hyperactive Member
Re: Adding "HTTP://" to URL's
Thanks for the reply, I'm having trouble getting it to work though
I'm not using a dataset in the site, just binding the data direct to the datagrid using the datasource, databind methods.
Would I be better off using a datagrid ? and do I have to use a datagrid to add the http:// ?
Sorry if these are daft question, but I'm still very green
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|