At work there is a gridview and it has the following syntax
<asp:HyperLinkField
DataNavigateUrlFields="NameID"
DataNavigateUrlFormatString="names.aspx?nameid={0}"
DataTextField="name"
HeaderText="Client Name"
SortExpression="Name"
ItemStyle-Width="100px"
ItemStyle-Wrap="true" />
So I added the line DataNavigateUrlFormatString... The link is showing properly but the address looks like this
http://.....clients/clientNames/names.aspx?nameid=123
This gridview is in the ClientsNames folder.. but I actually want to use the names.aspx of the maintenance folder... so Basically i want the U开发者_运维知识库RL to redirect like this
httpL//....clients/Maintenance/names.aspx?nameid=123
I tried to add DataNavigateUrlFormatString="Maintenance/names.aspx?nameid={0}" but instead it would create url like this
http://......clients/clientNames/Mainteanance/names.aspx?nameid=123
How can I make it so that the url looks like this from this grid view?
http://.....clients/Maintenance/names.aspx?nameid=123
Thank you
Try setting DataNavigateUrlFormatString to "../Maintenance/names.aspx?nameid={0}"
<asp:HyperLinkField
DataNavigateUrlFields="NameID"
DataNavigateUrlFormatString="../maintenance/names.aspx?nameid={0}"
DataTextField="name"
HeaderText="Client Name"
SortExpression="Name"
ItemStyle-Width="100px"
ItemStyle-Wrap="true" />
Use
DataNavigateUrlFormatString="~/clients/Maintenance/names.aspx?nameid={0}"
Or you can use GridView.RowDataBound event and set Url programmatically.
There's all kinds of wierd prefixes to try... I don't have a reference off-hand, but here are some:
DataNavigateUrlFormatString="~/names.aspx?nameid={0}" (starts at the root)
DataNavigateUrlFormatString="../names.aspx?nameid={0}" (starts in the parent's parent folder)
DataNavigateUrlFormatString="../../names.aspx?nameid={0}" (starts in the parent's parent's parent's folder)
精彩评论