我想按日期分组网格视图小计和总计 [英] I want to group by date Grid view Subtotal and grand total

查看:85
本文介绍了我想按日期分组网格视图小计和总计的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想按日期分组网格视图小计和总计的金额.

我可以使用带有pagin的gridview示例在c#中获得高效的代码.

I want to group by date Grid view Subtotal and grand total for an amount .

Can i get efficient code in c# with gridview example with pagin.

推荐答案

hi ...
我认为您可以通过2种方式做到这一点.

1)如果您使用sql server并使用存储过程,则
使用分组依据和汇总写查询,返回所需结果.
2)您可以创建结果集,例如
提取2个数据表,一个用于Distict日期,另一个用于带有详细信息的日期
hi...
I think you can do this in 2 ways.

1) If You use sql server and use Stored Procedure then
Write query with Group by and rollup which return your required result.
2) You can create result set like
Fetch 2 Datatable one for Distict Date and One for Date with Detail
 //Create Temp Table
  Datatable tmpdt=new Datatable();
//Add Data Columns in tmpdt.

  //Loop For Date
  for(i=0;i<dt.rows.count;i++)>
  {
    Decimal totAmt=0.0;
    for(j=0;j<=dtDetail.rows.countj++)
    {
       if(dt.rows[i]["Date"]==dtDetail.rows[j]["Date"])
       {
           totAmt=totAmt+convert.toDecimal(dtDetail.rows[j]["Date"]);
       }
    }
    Datarow dr;
    dr=dttmp.NewRow();
    //Add Detail
    tmpdt.rows.add(dr);
  }


//最后将数据源设置为grid


// Finally set data source to grid


这篇关于我想按日期分组网格视图小计和总计的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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