3 回答
TA贡献1871条经验 获得超8个赞
尝试这个:
foreach(GridViewRow row in GridView1.Rows) {
if(row.RowType == DataControlRowType.DataRow) {
HyperLink myHyperLink = row.FindControl("myHyperLinkID") as HyperLink;
}
}
如果要处理RowDataBound事件,则如下所示:
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if(e.Row.RowType == DataControlRowType.DataRow)
{
HyperLink myHyperLink = e.Row.FindControl("myHyperLinkID") as HyperLink;
}
}
TA贡献1853条经验 获得超9个赞
您可以使用此代码HyperLink在GridView中查找。用于e.Row.Cells[0].Controls[0]在GridView中查找控件的第一个位置。
protected void AspGrid_RowDataBound(object sender, GridViewRowEventArgs e)
{
if(e.Row.RowType == DataControlRowType.DataRow)
{
DataRowView v = (DataRowView)e.Row.DataItem;
if (e.Row.Cells.Count > 0 && e.Row.Cells[0] != null && e.Row.Cells[0].Controls.Count > 0)
{
HyperLink link = e.Row.Cells[0].Controls[0] as HyperLink;
if (link != null)
{
link.Text = "Edit";
}
}
}
}
TA贡献1777条经验 获得超3个赞
我已经完成了访问单元格控件内的控件的操作。在所有控件集合中查找。
ControlCollection cc = (ControlCollection)e.Row.Controls[1].Controls;
Label lbCod = (Label)cc[1];
- 3 回答
- 0 关注
- 638 浏览
添加回答
举报