2

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 URL 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

1
  • Thanks guys a vote for all :) Commented Jul 20, 2011 at 21:59

3 Answers 3

4

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" /> 
Sign up to request clarification or add additional context in comments.

4 Comments

i did this, i mentioned in the post
with the ../ in front of maintenance?
nothing else, just "../" followed by "maintenance/names.aspx?nameid={0}"
You may want to do "~/../maintenance/names.aspx..."
1

Use

DataNavigateUrlFormatString="~/clients/Maintenance/names.aspx?nameid={0}"

Or you can use GridView.RowDataBound event and set Url programmatically.

Comments

1

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)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.