0

Hope you are having a nice day.

I am developing a gridview for a list of songs with a hyperlink field like below. I left unnecessary codes by the way. The purpose of hyperlink field is for user to download songs. I am using visual studio 2010 and I am still using development server such as http://Localhost:xxxx/mypage.aspx. So I have to update the hyperlink field everytime I run this page in order to keep the link correct. I understand once i put on the live server, i just need to put the domain and this problem is fixed but I am wondering if there is a way to dynamically map the path of DataNavigateUrlFormatString to the development server URL so that I don't need to keep changing while I am on development server.

Thanks a lot.

    <asp:GridView>
    <Columns>
    <asp:BoundField DataField="Song_Name" HeaderText="Song_Name" SortExpression="Song_Name" />

    <asp:HyperLinkField DataNavigateUrlFields="Song_Location" 
     DataNavigateUrlFormatString="http://localhost:6686/RioMusic/Uploads/{0}" 
     DataTextField="Song_Name" HeaderText="Download" />
    </Columns>
    </asp:GridView>
Taz
  • 3,718
  • 2
  • 37
  • 59
Laurence
  • 7,633
  • 21
  • 78
  • 129

1 Answers1

1

Can you just use a relative link? I.e.:

Uploads/{0}

(This will be relative to the page displaying the link.)

Or, if you wish to specify a url relative from the root of your site:

~/RioMusic/Uploads/{0}
Carl Sharman
  • 4,435
  • 1
  • 30
  • 29
  • That should work but the problem is, if i don't put http://localhost/xxxx in it, it becomes unclickable for a reason. Any idea ? – Laurence Mar 05 '12 at 11:12
  • Sorry, i made it work now. the problem was DataNavigateUrlFields which was using Song_Location which is the actual location (eg. C://xxx/xxx/xx.mp3) that I saved in the database when I made the song uploads. I changed that to the name of the actually file and use ** ~/RioMusic/Uploads/{0} ** like this and works fine now. tHanks. – Laurence Mar 05 '12 at 11:21