我想从列表中获取值的总和。
例如:我在列表中有 4 个值 1 2 3 4 我想对这些值求和并将其显示在标签中
代码:
protected void btnCalculate_Click(object sender, EventArgs e)
{
string monday;
TextBox txtMonTot;
List<string> monTotal = new List<string>();
if (Application["mondayValues"] != null)
{
List<string> monValues = Application["mondayValues"] as List<string>;
for (int i = 0; i <= gridActivity.Rows.Count - 1; i++)
{
GridViewRow row = gridActivity.Rows[i];
txtMonTot = (TextBox)row.FindControl("txtMon");
monday = monValues[i];
monTotal.Add(monday);
}
}
}
有任何想法吗?提前致谢