Problem with Hyperlink in GridView

T

Tor Inge Rislaa

When I insert the complete querystring into the NavigateUrl tag this
hyperlink works fine within the GridView.



<asp:HyperLinkField HeaderText=" Details"
NavigateUrl="~/Admindetail.aspx?ku_id=1" Text="Details"





If I try to let the parameter data be provided dynamically something strange
happen. I can see that the dynamical data is provided, with the right ku_id,
but the aspx file is removed from the URL



<asp:HyperLinkField DataNavigateUrlFields="ku_id" HeaderText="Details"
NavigateUrl="~/Admindetail.aspx?ku_id={0}" Text="Details" />



The first code gives something like

www.mysite.com/Admindetail.aspx?ku_id=1



this works OK



The second code gives something like

www.mysite.com/1



Am I configuring it incorrect?





TIRislaa
 
M

Mohamad Elarabi

Tor,
the NavigateURL is only used when specifying the same link for all rows.
Text attribute is also static accreoss the board. If you want the link to
include a value from a data field you should use the DataNavigateURLField
with the DataNavigateURLFormatString. The same goes for DataTextField and
DataTextFormatString if you want the link text to also be dynamic. Your tag
should look something like this

<asp:HyperLinkColumn
HeaderText="View Detail"
DataNavigateUrlField="ku_id"
DataNavigateUrlFormatString="~/Admindetail.aspx?ku_id={0}"
DataTextField="ku_id"
DataTextFormatString="Details for Record {0}" />

Good luck,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,225
Members
46,815
Latest member
treekmostly22

Latest Threads

Top