如何将gridview中的每个数据超链接到不同的页面? [英] How to make each data in gridview hyperlink to different pages?
问题描述
上。
我正在使用Visual Studio(vb.net),gridview(visual studio的工具箱中的功能),数据与SQL数据源绑定。至于上面的问题。让我说我有这组数据
---------------
否|项目
--------------
1 | Apple
2 |橙色
如果我点击Apple,它将重定向到仅显示苹果详情的页面。如果我点击橙色,它会重定向到另一个只会显示橙色细节的页面。
谢谢。
我尝试了什么:
< asp:HyperLinkField DataTextField =Total GuarantorText =Total担保人HeaderText =总担保人NavigateUrl =〜/ guarantoedetails.aspx/>
此代码生成结果:
(采取上面的示例数据集)
如果我点击'apple'或'Orange',它将重定向到相同的页面。
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.
推荐答案
您好,
超链接控件中有一个名为Target的属性。这些是Target属性的细节。
_blank :在没有框架的新窗口中呈现内容。
_parent :在即时框架集父级中呈现内容。
_search :在搜索窗格中呈现内容。
_self :使用焦点渲染框架中的内容。
_top :在没有框架的完整窗口中渲染内容。
所以你的解决方案将是:
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:
<asp:hyperlinkfield target="_blank" datatextfield=" total guarantor" text="Total Guarantor" headertext="Total Guarantor" navigateurl="~/guarantoedetails.aspx" />
无需转到不同的页面。你可以传递像QueryString这样的数据...
No need to go to different pages. You can pass the data i QueryString like...
<asp:HyperLinkField DataTextField="Total Guarantor" Text="Total Guarantor" HeaderText="Total Guarantor" NavigateUrl='<%# string.Format("~/guarantoedetails.aspx?Item={0}", Eval("Item").ToString()) %>' />
这篇关于如何将gridview中的每个数据超链接到不同的页面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!