我想统计GridView
总数,我的for
循环出了什么问题?如何计算gridview单元格
public void Bind()
{
//Assign the datasource to GridView
this.grdCart.DataSource = Get_Arealist();
//Databind the grid
this.grdCart.DataBind();
decimal a = 0, c = 0;
for (int i = 0; i <= (grdCart.Rows.Count); i++)
{
a = Convert.ToDecimal(grdCart.Rows[i].Cells[3].Text.ToString());
c = c + a; //storing total qty into variable
c++;
}
Label2.Text = c.ToString();
}
什么总数?你想要4rth列中所有单元格的数字总和吗? –
如果我改变int它也不工作,雅我想总结4rth列 – Mickey
你不想要C++ – NoChance