Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#
I have a two gridview.Have column in both are,
 
first:

code Tax% TaxAmount
1 3 0.73
2 4 1.3
3 3 0.92
 

Second:

Tax% TaxAmount
3 1.65
4 1.3
 
as per above mentioned when we have same Tax% in 1st grid,it will add and shows the sum in another grid.
 
so let me know how to do this please...
please help sumbody..
Posted 1-Oct-12 19:59pm
Edited 7-Oct-12 20:55pm
v3
Comments
Shivani Dash at 2-Oct-12 2:39am
   
Can nebody help me plz...
Santhosh Kumar J at 8-Oct-12 3:24am
   
You got the solution?
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

This is not an exact answer to your question, however, it might just help you get started - CodeProject Frequently Asked Questions Series 1: The ASP.NET GridView[^].
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

try this
 
 DataTable dt = new DataTable();
            DataRow dr = dt.NewRow();
            dt.Columns.Add("code", typeof(int));
            dt.Columns.Add("Tax", typeof(int));
            dt.Columns.Add("Amount", typeof(decimal));
            dr["code"] = 1;
            dr["tax"] = 3;
            dr["Amount"] = 0.73;
            dt.Rows.Add(dr);
            DataRow dr1 = dt.NewRow();
            dr1["code"] = 2;
            dr1["tax"] =4;
            dr1["Amount"] =1.3;
            dt.Rows.Add(dr1);
            DataRow dr2 = dt.NewRow();
            dr2["code"] = 3;
            dr2["tax"] = 3;
            dr2["Amount"] = 0.92;
            dt.Rows.Add(dr2);
            DataTable dt1 = new DataTable();
 
            dt1.Columns.Add("Tax", typeof(int));
            dt1.Columns.Add("TotalAmount", typeof(decimal));
            
            var query = from row in dt.AsEnumerable()
                        group row by row.Field<int>("Tax") into grp
                        select new
                        {
                            tax = grp.Key,
                            sum = grp.Sum(r => r.Field<decimal>("Amount"))
                        };
            foreach (var grp in query)
            {
                DataRow row = dt1.NewRow();
                row["Tax"] = grp.tax;
                row["TotalAmount"] = grp.sum;
                dt1.Rows.Add(row);
            }
          
  Permalink  
v2

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

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 424
1 Nirav Prabtani 298
2 OriginalGriff 199
3 _Amy 165
4 Maciej Los 145
0 OriginalGriff 7,755
1 Sergey Alexandrovich Kryukov 6,951
2 Maciej Los 3,994
3 Peter Leow 3,698
4 CHill60 2,742


Advertise | Privacy | Mobile
Web01 | 2.8.140721.1 | Last Updated 8 Oct 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100