Click here to Skip to main content
12,999,833 members (52,041 online)
Rate this:
Please Sign up or sign in to vote.
See more:
I have a two gridview.Have column in both are,


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


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
Updated 7-Oct-12 20:55pm
Shivani Dash 2-Oct-12 2:39am
Can nebody help me plz...
Santhosh Kumar J 8-Oct-12 3:24am
You got the solution?
Rate this: bad
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[^].
Rate this: bad
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;
            DataRow dr1 = dt.NewRow();
            dr1["code"] = 2;
            dr1["tax"] =4;
            dr1["Amount"] =1.3;
            DataRow dr2 = dt.NewRow();
            dr2["code"] = 3;
            dr2["tax"] = 3;
            dr2["Amount"] = 0.92;
            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"] =;
                row["TotalAmount"] = grp.sum;

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web01 | 2.8.170624.1 | Last Updated 8 Oct 2012
Copyright © CodeProject, 1999-2017
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