如何在GridView中使用“超链接"列? [英] How to use Hyperlink column in GridView?
本文介绍了如何在GridView中使用“超链接"列?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
请检查以下代码.
我想将超链接绑定到gridview column1.该列来自DataSet
.
如何将超链接绑定到ds以及如何绑定到网格视图?
Please check the following code.
I want to bind hyperlink to the gridview column1. The column comes from DataSet
.
How to bind hyperlink to the ds and how to bind to grid view?
con = DBconnection.getconnection()
ds = BLLFactory.coursebooks3().course()
If ds.Tables(0).Rows.Count > 0 Then
For j = 0 To ds.Tables(0).Rows.Count - 1
hfield = New HyperLinkField()
hfield.HeaderText = ds.Tables(0).Rows(j)(1)
hfield.NavigateUrl = "somepage.aspx"
hfield.DataTextField = ds.Tables(0).Rows(j)(1).ToString()
GridView1.Columns.Add(hfield)
bfield1 = New BoundField()
bfield1.HeaderText = ds.Tables(0).Rows(j)(1)
bfield1.DataField = ds.Tables(0).Rows(j)(1).ToString()
GridView1.Columns.Add(bfield1)
''GridView1.DataSource = ds.Tables(0)
GridView1.DataBind()
Next
End If
End Sub
推荐答案
我认为您必须使用
hfield.DataTextField ="NameOfTheFieldInDataSet"
它将使用该字段的内容作为超链接的文本
I think you must use
hfield.DataTextField = "NameOfTheFieldInDataSet"
and it will use the content of the field for the text of the hyperlink
这篇关于如何在GridView中使用“超链接"列?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文