ASP中GridView中求汇总。。。该怎样???? 应付费用 实付费用 其它费用 这是GridView中的三个字段。可以不在GridView 中增加一行用来显示汇总的钱数。我只要三个费用的总数就行! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 这好办啊,直接在绑定之前,你取出数据,在内存里面直接row.add()加一行,并且计算出数值填充进去,然后再绑定就可以了 protected void gvwInfo_RowDataBound(object sender, GridViewRowEventArgs e) { // 合计 if (e.Row.RowType == DataControlRowType.DataRow) { DataRowView myrows = (DataRowView)e.Row.DataItem; num1 += Convert.ToInt32(myrows[2].ToString()); num2 += Convert.ToInt32(myrows[3].ToString()); num3 += Convert.ToInt32(myrows[4].ToString()); num4 += Convert.ToInt32(myrows[5].ToString()); num5 += Convert.ToInt32(myrows[6].ToString()); num6 += Convert.ToInt32(myrows[7].ToString()); num7 += Convert.ToInt32(myrows[8].ToString()); } // 合计 if (e.Row.RowType == DataControlRowType.Footer) { e.Row.Cells[0].Text = "合计"; e.Row.Cells[1].Text = @"<asp:LinkButton ID='link1' OnClick='link1_Click' runat='server'>"+num1.ToString()+"</asp:LinkButton>"; e.Row.Cells[2].Text = "<a href='htddtp://www.sohu.com' > "+num2.ToString()+"<a/>"; e.Row.Cells[3].Text = num3.ToString(); e.Row.Cells[4].Text = num4.ToString(); e.Row.Cells[5].Text = num5.ToString(); e.Row.Cells[6].Text = num6.ToString(); e.Row.Cells[7].Text = num7.ToString(); } } 怎么数都 是固定 的呀....我不知道有多少行呀!!!--------------------------------看不懂,michaelowenii 的是可以的,建议你,在查询数据的时候就将汇总这项工作完成,而不是留在 UI 上处理 这个新浪微博秀是如何生成的 gridview新手问题 asp.net 存储过程,我要返回记录集,和记录总数 DataList分页???? GridView里删除会报错? 程序员和美工哪个在前哪个在后? dropdownlist在自定义控件里,该怎么用???(在线等,急) 散分了来 我做的分页怎么老是出错? 可以抓取其他站点上的新闻,改头换面一下,放到我自己的网站上去吗?icyer Help!!! 在线等待:FCKeditor输入的内容如何保证不让英文单词跨行显示? 急!!!!! 关于Javascript操作列表框.
protected void gvwInfo_RowDataBound(object sender, GridViewRowEventArgs e)
{
// 合计
if (e.Row.RowType == DataControlRowType.DataRow)
{
DataRowView myrows = (DataRowView)e.Row.DataItem;
num1 += Convert.ToInt32(myrows[2].ToString());
num2 += Convert.ToInt32(myrows[3].ToString());
num3 += Convert.ToInt32(myrows[4].ToString());
num4 += Convert.ToInt32(myrows[5].ToString());
num5 += Convert.ToInt32(myrows[6].ToString());
num6 += Convert.ToInt32(myrows[7].ToString());
num7 += Convert.ToInt32(myrows[8].ToString());
}
// 合计
if (e.Row.RowType == DataControlRowType.Footer)
{
e.Row.Cells[0].Text = "合计";
e.Row.Cells[1].Text = @"<asp:LinkButton ID='link1' OnClick='link1_Click' runat='server'>"+num1.ToString()+"</asp:LinkButton>";
e.Row.Cells[2].Text = "<a href='htddtp://www.sohu.com' > "+num2.ToString()+"<a/>";
e.Row.Cells[3].Text = num3.ToString();
e.Row.Cells[4].Text = num4.ToString();
e.Row.Cells[5].Text = num5.ToString();
e.Row.Cells[6].Text = num6.ToString();
e.Row.Cells[7].Text = num7.ToString();
}
}
--------------------------------
看不懂,michaelowenii 的是可以的,建议你,在查询数据的时候就将汇总这项工作完成,而不是留在 UI 上处理