Click here to Skip to main content
15,893,594 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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.
Posted
Comments
saifulhaque 10-Nov-11 2:54am    
http://www.dotnettwitter.com/2011/02/group-total-grand-total-in-grid-view.html

You can see this page
I want sort amount by date instred of year.In this two sub total i need only one and grand total from using database instred of xml file

1 solution

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);
  }

// Finally set data source to grid
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900