我想得到gvProducts
行数。
我已经尝试过下面的代码,但它给出的结果不足。
protected void gvProducts_RowCommand(object sender, GridViewCommandEventArgs e)
{
string commandName = e.CommandName.ToString().Trim();
GridViewRow row = (GridViewRow)(((LinkButton)e.CommandSource).NamingContainer);
if (row.Controls.Count == 1)
{
//my code
}
}
您想要 Gridview 中的总行数吗?使用Count
财产:
gvProducts.Rows.Count
Update:
要查找嵌套 gridview 的行数,您可以使用RowDataBound
父网格视图的事件:-
protected void gvProductsParent_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
GridView gvProducts = (GridView)e.Row.FindControl("gvProducts ");
int count = gvProducts.Rows.Count;
}
}
请注意,此事件将针对父网格视图中存在的每一行触发count
将根据每一行而变化。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)