12,999,833 members (52,041 online)
Rate this:
See more:
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...
Posted 1-Oct-12 19:59pm
Updated 7-Oct-12 20:55pm
v3
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:

Rate this:

## Solution 2

try this

``` DataTable dt = new DataTable();
DataRow dr = dt.NewRow();
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();

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;
}```
v2

Top Experts
Last 24hrsThis month
 RickZeeland 185 OriginalGriff 40 Michael_Davies 40 ppolymorphe 40 Bharat Leel 35
 OriginalGriff 4,547 ppolymorphe 2,292 RickZeeland 2,142 Kornfeld Eliyahu Peter 1,973 Richard Deeming 1,593