日期:2014-05-18 浏览次数:20637 次
HyperLink href = (HyperLink)e.Row.Cells[6].Controls[];
href.NavigateUrl = "12345678.asp";
public DataSet TdataSet(string ContraAct,string RefDate,string DueDate)
{
string QueryString = "select * from Test";
SqlAdpter.SelectCommand = new SqlCommand(QueryString,SqlConn);
SqlAdpter.Fill(ds, "user");
return ds;
}
<ItemTemplate>
<asp:HyperLink ..../>
</ItemTemplate>
------解决方案--------------------
我用的是ObjectDataSource,没有直接数据绑定,请各位指点一下。
====
模板列中a链接属性绑定 方法
------解决方案--------------------
我在GridView中填充自己的数据,怎么样能在填充的同时在指定的列添加超链接?(不是新增一列,而是读出的指定列)
==
如果打算使用编程的方式,必须自己在后台用代码创建模版列
------解决方案--------------------
Protected Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView1.RowDataBound
If e.Row.RowType = DataControlRowType.DataRow Then
Dim drv As System.Data.DataRowView = CType(e.Row.DataItem, DataRowView)
Dim link As HyperLink
link = CType(e.Row.FindControl("hyp"), HyperLink)
link.NavigateUrl = drv("pic_path")
link.Text = "动态生成的连接"
End If
End Sub
------解决方案--------------------
<ItemTemplate>
<asp:HyperLink ..../>
</ItemTemplate
或者
<asp:TemplateField HeaderText="列名">
<ItemTemplate>
<a href="12345678.asp"> <%# Eval("DataFieldName") %> </a>
</ItemTemplate>
</asp:TemplateField>