質問

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>
役に立ちましたか?

解決

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}
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top