[英]Is it possible to loop through RowDataBound?
是否可以捕获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");
}
}
我有一些需要在每次迭代中动态更改的值。
使用e.Row.RowIndex
查找迭代索引:
HtmlGenericControl hgcsampleNum = gvExample.Rows[e.Row.RowIndex]
.FindControl("sample") as HtmlGenericControl;
或者,您可以在RowDataBound事件中使用e.Row.FindControl
:
HtmlGenericControl hgcsampleNum = e.Row.FindControl("sample") as HtmlGenericControl;
两者都一样。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.