首先定一个足够大的整型数组MyCount
还有这里假设你的值为可以转化为整形的。private void DataGrid1_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
{
if ( e.Item.ItemIndex >= 0 )
{
for ( int i = 1; i < e.Item.Cells.Count; i++ )
{
if ( e.Item.Cells[i].Text.ToString().Trim() != " " )
{
MyCount[i] += int.Parse( e.Item.Cells[i].Text );
}
}
}
else if (e.Item.ItemType == ListItemType.Footer)
{
e.Item.Cells[0].Text = "合计";
e.Item.Cells[0].Font.Bold = true;
e.Item.Cells[0].HorizontalAlign = HorizontalAlign.Center;
for ( int i = 1; i < e.Item.Cells.Count; i++ )
{
//MyCount[i]现在存的是累加值,你可以求平均数
e.Item.Cells[i].Text = MyCount[i].ToString();
e.Item.Cells[i].Font.Bold = true;
}
}
}
还有这里假设你的值为可以转化为整形的。private void DataGrid1_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
{
if ( e.Item.ItemIndex >= 0 )
{
for ( int i = 1; i < e.Item.Cells.Count; i++ )
{
if ( e.Item.Cells[i].Text.ToString().Trim() != " " )
{
MyCount[i] += int.Parse( e.Item.Cells[i].Text );
}
}
}
else if (e.Item.ItemType == ListItemType.Footer)
{
e.Item.Cells[0].Text = "合计";
e.Item.Cells[0].Font.Bold = true;
e.Item.Cells[0].HorizontalAlign = HorizontalAlign.Center;
for ( int i = 1; i < e.Item.Cells.Count; i++ )
{
//MyCount[i]现在存的是累加值,你可以求平均数
e.Item.Cells[i].Text = MyCount[i].ToString();
e.Item.Cells[i].Font.Bold = true;
}
}
}
解决方案 »
- 总是转到验证码错误页面
- 路径文件访问被拒绝问题
- 读数据库字段值并输出到网页时出错!! 哭
- 关于发邮件问题~!马上给分
- 页面没有Body 怎么获取onload="setup()"
- ■■■请教一个正则表达式的问题
- 大家看看,ASPNET的这个语句应该怎么写啊<a href=reply.aspx?id=<%response.write(request.querystring("id"))%> target=_self>
- 如何做鼠标放到DataGrid的一行上,那行的背景颜色变为黄色,移开鼠标后又变为以前的颜色??
- 办成此事者,得所放全部分数
- asp.net初学者的问题,谢谢!
- 求一个比较完备的社区/论坛的数据库设计文档,在线等!!!
- 新手的苦恼
http://expert.csdn.net/Expert/topic/1435/1435648.xml?temp=.9566309