在ROWDATABOUND事件里统计编写,看看MSDN关于此事件的介绍。
解决方案 »
- WebClient.UploadFile()
- 有用.net做个CMS的吗?
- (急)对Repeater控件中绑定的数据进行更新问题
- 可不可以帮我调试一下这个程序,快疯啦
- Request.ServerVariables["HTTP_REFERER"]有时候获取不到,怎么回事?
- 有关用户登录,验证的问题
- 配置错误 访问被拒绝:“Webad“ 怎麽回事了
- 求大图片的处理办法:缩放、平移、热点map
- 请教达人:有关ASP报错:“ASP.default_aspx”并不包含“MyMenu_MenuItemClick”的定义
- asp.net c# 怎么能验证 某个 代理服务器是否可用?
- 菜鸟小弟单位任务到了最后关头,深夜编写代码受阻求助SQL查询字符串问题(VS2003,VB.NET)
- 页面换肤
int y = 0;
protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e)
{
switch (e.Row.Cells[4].Text)
{
case "按时":
x += 1;
break;
case "延期":
y += 1;
break;
default:
break;
}
}
强烈建议你看看MSDN ROWDATABOUND
int x = 0;
int y = 0; protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
switch (e.Row.Cells[4].Text)
{
case "按时完工":
x += 1;
break;
case "延期完工":
y += 1;
break;
default:
break;
}
// 自动统计
if (e.Row.RowType == DataControlRowType.Footer) { float f = ((float)(x + y) / GridView1.Rows.Count) * 100; String str = String.Format("{0:f1}", f); e.Row.Cells[3].Text = str + "%";
e.Row.Cells[5].Text = x.ToString(); e.Row.Cells[7].Text = y.ToString();
} }
int y = 0;
protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e)
{
switch (e.Row.Cells[4].Text)
{
case "按时完工":
x += 1;
break;
case "延期完工":
y += 1;
break;
default:
break;
}
}
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
// 自动统计
if (e.Row.RowType == DataControlRowType.Footer) { float f = ((float)(x + y) / GridView1.Rows.Count) * 100; String str = String.Format("{0:f1}", f); e.Row.Cells[3].Text = str + "%";
e.Row.Cells[5].Text = x.ToString(); e.Row.Cells[7].Text = y.ToString();
}出现的结果是x,y没有自增,在最后的统计结果中仍然是0.若照only-endure的方法,代码已在上面,出现的结果是“指定的参数已超出有效值的范围。参数名: index”这是为什么呢??
if(e.Row.RowType == DataControlRowType.DataRow)
{ switch (e.Row.Cells[4].Text)
{
case "按时完工":
x += 1;
break;
case "延期完工":
y += 1;
break;
default:
break;
}
晕,我不是说过了么,这些数据的东西都放在ROWDATABOUND事件中。
int x = 0;
int y = 0;
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{ // 自动统计
switch (e.Row.Cells[4].Text)
{
case "按时完工":
x += 1;
break;
case "延期完工":
y += 1;
break;
default:
break;
}
}
else if (e.Row.RowType == DataControlRowType.Footer)
{ float f = ((float)(x + y) / GridView1.Rows.Count) * 100; String str = String.Format("{0:f1}", f); e.Row.Cells[3].Text = str + "%"; e.Row.Cells[5].Text = x.ToString(); e.Row.Cells[7].Text = y.ToString(); }
}
int y = 0;
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{ // 自动统计
//ken update
switch (e.Row.Cells[4].Text.Trim())
{
case "按时完工":
x += 1;
break;
case "延期完工":
y += 1;
break;
default:
break;
}
}
if (e.Row.RowType == DataControlRowType.Footer)
{ float f = ((float)(x + y) / GridView1.Rows.Count) * 100; String str = String.Format("{0:f1}", f); e.Row.Cells[3].Text = str + "%"; e.Row.Cells[5].Text = x.ToString(); e.Row.Cells[7].Text = y.ToString(); }
}