我想統計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