RadGrid 列中的可点击链接
我有一个 RadGrid,其中网格中的一列包含一个 URL。当在列中输入值时,我可以看到 URL,但该 URL 不可单击(以转到该 URL)。如何使 URL 可点击?
这是我现在正在做的一个粗略示例:
DataTable table = new DataTable();
DataRow row = table.Rows[0];
row["URL"] = "http://www.google.com";
grid.DataSource = table;
此外,我真的很想显示特定的文本而不是 URL。类似于 HTML 中的 Link
。有办法做到这一点吗?
I have a RadGrid where a column in the grid holds a URL. When a put a value in the column I can see the URL but the URL is not clickable (to go to the URL). How can I make the URL clickable?
Here is a rough example of what I'm doing now:
DataTable table = new DataTable();
DataRow row = table.Rows[0];
row["URL"] = "http://www.google.com";
grid.DataSource = table;
In addition I'd really like to show specific text instead of the URL. Something similar to <a href="http://www.google.com">Link</a>
in HTML. Is there anyway to do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您尝试过 GridHyperLinkColumn 吗?下面是一个详细的例子。
您还可以查看演示网站以了解其工作原理。
http://demos.telerik.com/aspnet-ajax /grid/examples/generalfeatures/columntypes/defaultcs.aspx
Have you tried the GridHyperLinkColumn? Below is a detailed example.
You can also view the demosite to see how it works.
http://demos.telerik.com/aspnet-ajax/grid/examples/generalfeatures/columntypes/defaultcs.aspx
在 ascx 页面中手动添加所有列,并将要包含超链接的列设为 GridTemplateColumn:
确保网格具有 OnItemDataBound 方法:
在 OnItemDataBound 方法中将字段设置为 URL:
Add all the columns manually in the ascx page and make the column you want to contain the hyperlink a GridTemplateColumn:
Make sure that your grid has an OnItemDataBound method:
In your OnItemDataBound method set the field to the URL:
您还需要检查类型是否正确,如下所示;
You will also need to check for the correct type, as follows;