在GridView中计算多个累积频率 [英] calculating multiple cumulative frequency in gridview

查看:106
本文介绍了在GridView中计算多个累积频率的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨 我需要像这样计算累积频率:
a b c
1 2 2
1 3 5
1 6 11
2 4 4
2 1 5
2 5 10
3 2 2
3 4 6

但是
对我来说,输出越来越像这样

a b c
1 2 2
1 3 5
1 6 11
2 4 4
2 1 5
2 5 10
3 2 12
3 4 16

我的编码是:

 ArrayList dataArray =  ArrayList();


    for ( int  rowIndex = gv1.Rows.Count- 2 ; rowIndex >   0 ; rowIndex--)
   {


   //  for(int rowIndex = 1; rowIndex< gv1.Rows.Count; rowIndex ++)
   //  {

       //  int rowIndex = gv1.Rows.Count; 
       //  GridViewRow row1 = gv1.Rows [rowIndex]; 
       GridViewRow previousRow = gv1.Rows [rowIndex +  1 ];
        int  c1 =  0 ;
        int  cv1 =  0 ;


        foreach (GridViewRow row1  in  gv1.Rows中)
       {
           //  for(int i = 0; i< row1.Cells.Count; i ++)
           //  {

               如果(row1.Cells [ 1 ].Text!= previousRow.Cells [//  row2 = row1; 
                   cv1 = System.Convert.ToInt32(row1.Cells [ 4 ].Text);
                   c1 + = cv1;
                   row1.Cells [ 5 ].Text = c1.ToString();
                   dataArray.Add(c1);
               }

           // } 
       }

       //  break; 
           }



谁能对我说这个建议

解决方案

您没有问类似的ArrayList dataArray = new ArrayList(); for (int rowIndex = gv1.Rows.Count - 2; rowIndex > 0; rowIndex--) { //for (int rowIndex = 1; rowIndex < gv1.Rows.Count; rowIndex++) //{ //int rowIndex = gv1.Rows.Count; //GridViewRow row1 = gv1.Rows[rowIndex]; GridViewRow previousRow = gv1.Rows[rowIndex + 1 ]; int c1 = 0; int cv1 = 0; foreach (GridViewRow row1 in gv1.Rows) { //for (int i = 0; i < row1.Cells.Count; i++) //{ if (row1.Cells[1].Text != previousRow.Cells[1].Text) { //row2 = row1; cv1 = System.Convert.ToInt32(row1.Cells[4].Text); c1 += cv1; row1.Cells[5].Text = c1.ToString(); dataArray.Add(c1); } //} } //break; }



can any one say me the suggestion for this

解决方案

Did you not ask a similar question a few days ago[^]?


这篇关于在GridView中计算多个累积频率的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆