GridView里的数据已经绑定好了:
有个字段需要变成超链接。
不可能预先设置模板列了,怎么用代码给某个字段的文字加上超链接啊?我再贴点代码,我是这么做的,但不成功。for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
ds.Tables[0].Rows[i]["学号"]= getURL(i);
GridView1.DataSource = ds;
GridView1.DataBind();
我要做的就是把超链接写进HTML里。
有个字段需要变成超链接。
不可能预先设置模板列了,怎么用代码给某个字段的文字加上超链接啊?我再贴点代码,我是这么做的,但不成功。for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
ds.Tables[0].Rows[i]["学号"]= getURL(i);
GridView1.DataSource = ds;
GridView1.DataBind();
我要做的就是把超链接写进HTML里。
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Cells[0].Text = "<a href=''>例子</a>";
}
}
The RowDataBound event is raised when a data row (represented by a GridViewRow object) is bound to data in the GridView control.