Click here to Skip to main content
15,888,454 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hai.

I'm using Visual Studio(vb.net), gridview( function in toolbox of visual studio)and the data is binding with SQL Data Source. As for the question above. Lets say I have this set of data

---------------
No | Item
--------------
1 | Apple
2 | Orange

If I click 'Apple' , it will redirect to page that will show details of apples only. Same if I click 'Orange' , it will redirect to another pages that will show details of orange only.

Thank You.

What I have tried:

<asp:HyperLinkField DataTextField="Total Guarantor" Text="Total Guarantor" HeaderText="Total Guarantor" NavigateUrl="~/guarantoedetails.aspx" />

This code produce results :
(took the example data set above)
If I click 'apple' or 'Orange' , it will redirect to same pages.
Posted
Updated 16-Jan-17 23:34pm
v2

Hello,

There is one property called "Target" in hyperlink control. These are the detail of Target property.
_blank: Renders the content in a new window without frames.
_parent: Renders the content in the immediate frameset parent.
_search: Renders the content in the search pane.
_self: Renders the content in the frame with focus.
_top: Renders the content in the full window without frames.
So your solution would be:
HTML
<asp:hyperlinkfield target="_blank" datatextfield=" total guarantor" text="Total Guarantor" headertext="Total Guarantor" navigateurl="~/guarantoedetails.aspx" />
 
Share this answer
 
Comments
Member 12882545 17-Jan-17 21:33pm    
Thank you for you answer. But I still get the same results:( . The difference is only when I click the data, it will open on a new tab instead on the same tab.
Sunasara Imdadhusen 19-Jan-17 6:05am    
You can use _self instead _blank if you want to open within the same page
Member 12882545 19-Jan-17 20:22pm    
Thank you . But it still did not solve my original problem, as I want each different data in the gridview will hyperlink to different page. The solution that you gave , when I clicked the data, it will direct to the same page? Is it possible for each different data to hyperlink to different page?
No need to go to different pages. You can pass the data i QueryString like...
HTML
<asp:HyperLinkField DataTextField="Total Guarantor" Text="Total Guarantor" HeaderText="Total Guarantor" NavigateUrl='<%# string.Format("~/guarantoedetails.aspx?Item={0}", Eval("Item").ToString()) %>' />
 
Share this answer
 
Comments
Member 12882545 17-Jan-17 21:25pm    
Thank you for the answer. But I got this error:

Databinding expressions are only supported on objects that have a DataBinding event. System.Web.UI.WebControls.HyperLinkField does not have a DataBinding event.

May I know the reasons?
Can you check the rendered html? There is a small mistake int he syntax, I guess.

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