Click here to Skip to main content
15,891,409 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I want to add the "Default.aspx" page as the resource for the dynamically loaded hyperlink in the gridview...

The hyperlinks are also loaded in the gridview dynamically.
Posted

1 solution

Hi,
You need to use RowCreated event handler of your GridView and in the handler set the NavigateUrl:

C#
void RowCreated...
{
   ((HyperLink)e.Row.FindControl("HyperLindName")).NavigateUrl = "~/Default.aspx"
}


I hope it will help,
Cheers.
 
Share this answer
 
v3
Comments
ZurdoDev 5-Apr-12 12:40pm    
I have not tested this but you will likely have to cast FindControl('...') as a HyperLink object to be able to set its NavigateUrl.
Reza Ahmadi 5-Apr-12 13:18pm    
Yes you need to cast it:
((HyperLink)e.Row.FindControl("HyperLindName")).NavigateUrl = "~/Default.aspx"
My main point is that you need to set the HyperLink in the RowCreated handler.
Member 8587164 6-Apr-12 23:26pm    
Hi
Thanks
While using this code "null reference exception" come. what should be placed inside this FindControl("??????")..
Reza Ahmadi 6-Apr-12 23:50pm    
The name of your HyperLink control. Try to debug your application to watch all existing controls in the e.Row
Member 8587164 7-Apr-12 10:17am    
Thanx a lot

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900