3 回答

TA貢獻(xiàn)1871條經(jīng)驗(yàn) 獲得超8個(gè)贊
嘗試這個(gè):
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貢獻(xiàn)1853條經(jīng)驗(yàn) 獲得超9個(gè)贊
您可以使用此代碼HyperLink在GridView中查找。用于e.Row.Cells[0].Controls[0]在GridView中查找控件的第一個(gè)位置。
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貢獻(xiàn)1777條經(jīng)驗(yàn) 獲得超3個(gè)贊
我已經(jīng)完成了訪問單元格控件內(nèi)的控件的操作。在所有控件集合中查找。
ControlCollection cc = (ControlCollection)e.Row.Controls[1].Controls;
Label lbCod = (Label)cc[1];
- 3 回答
- 0 關(guān)注
- 659 瀏覽
添加回答
舉報(bào)