是否有可能捕获RowDataBound的特定迭代?
protected void gvProposals_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
HtmlGenericControl hgcsampleNum = gvExample.Rows[*iteration*]
.FindControl("sample") as HtmlGenericControl;
hgcsampleNum .Attributes.Add("style", "width: 75%; height: 20px");
}
}我有需要在每次迭代中动态更改的值。
发布于 2017-12-14 06:26:13
使用e.Row.RowIndex查找迭代索引:
HtmlGenericControl hgcsampleNum = gvExample.Rows[e.Row.RowIndex]
.FindControl("sample") as HtmlGenericControl;或者,您可以在e.Row.FindControl事件中使用RowDataBound:
HtmlGenericControl hgcsampleNum = e.Row.FindControl("sample") as HtmlGenericControl;两者是一样的。
https://stackoverflow.com/questions/47802277
复制相似问题