如何添加超链接到网格和我希望从Sqldatabase添加URL的超链接 [英] How Can I Add Hyperlink To The Grid And For That Hyperlink I Want To Add Url From The Sqldatabase

查看:147
本文介绍了如何添加超链接到网格和我希望从Sqldatabase添加URL的超链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

LinkBut​​ton lnkBtn =(LinkBut​​ton)e.CommandSource; //按钮

GridViewRow myRow =(GridViewRow)lnkBtn.Parent.Parent; //行

GridView myGrid =(GridView)发送者; // gridview

字符串ID = myGrid.DataKeys [myRow.RowIndex] .Value.ToString();



这里我得到了id作为www.google.com,现在我想将它分配给链接或超链接buttom,以便它必须打开该链接

LinkButton lnkBtn = (LinkButton)e.CommandSource; // the button
GridViewRow myRow = (GridViewRow)lnkBtn.Parent.Parent; // the row
GridView myGrid = (GridView)sender; // the gridview
string ID = myGrid.DataKeys[myRow.RowIndex].Value.ToString();

here i got id as www.google.com,, now i want to assign it to link or hyperlink buttom so that it must open that link

推荐答案

点击gridview的智能标记和点击添加新列。在那里,您将获得添加字段选项。检查一下。
click on smart tag of gridview and click on add new column. There you will get add field options. Check it.


您好



我认为您从SQL填充了Gridview。现在让我们假设您在Gridview中有一个包含URL的列 LINK 。现在转到网格视图智能标记,然后单击添加新列。选择选择字段类型作为超链接字段。提供标题文本。从从数据字段中获取文本中选择正确的字段。从从数据字段获取URL 中选择正确的字段。将目标设置为 _blank 。将在新标签中打开网址。点击确定。

构建并运行。当您点击链接时,它将会打开那个链接。



祝你好运。
Hi

I think you are populated your Gridview from SQL. Now let us say that you have a column LINK in Gridview which contains URL. Now go to grid view smart tag and click on Add new column. Select choose a field type as Hyperlink field. Provide a Header Text.Select correct field from get text from data field.Select correct field from get URL from data field. Set Target to _blank.So url will be opened in new tab.Click ok.
build and run.When you click the link it will open that link.

Good Luck.


是的。我观察到了。我用 http://Google.com 尝试了它,它正在重定向到它。我将检查解决方案。
Yeah. I observed it. I tried it with http://Google.com and it was redirecting to that. I will check for solutions.


这篇关于如何添加超链接到网格和我希望从Sqldatabase添加URL的超链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆