Hi arulkumar,
Refer below example.
C#
protected void Page_Load(object sender, EventArgs e)
{
DataTable dt = new DataTable();
dt.Columns.Add("Item");
dt.Columns.Add("Qty");
dt.Columns.Add("Price");
dt.Rows.Add("a", 1, 10);
dt.Rows.Add("b", 2, 20);
dt.Rows.Add("c", 3, 30);
dt.Rows.Add("", 3, 0);
dt.Rows.Add("a", 4, 0);
dt.Rows.Add("a", 4, 0);
var result = (from dr in dt.AsEnumerable()
group dr by new { Name = dr["Item"], Qty = dr["Qty"] } into g
select new
{
Name = g.Key.Name,
Count = g.Count()
}).ToList();
}
VB.Net
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
Dim dt As DataTable = New DataTable()
dt.Columns.Add("Item")
dt.Columns.Add("Qty")
dt.Columns.Add("Price")
dt.Rows.Add("a", 1, 10)
dt.Rows.Add("b", 2, 20)
dt.Rows.Add("c", 3, 30)
dt.Rows.Add("", 3, 0)
dt.Rows.Add("a", 4, 0)
dt.Rows.Add("a", 4, 0)
Dim result = (From dr In dt
Group By x = New With {Key .Name = dr("Item"), Key .Qty = dr("Qty")} Into g = Group
Select New With {
.Name = x.Name,
.Count = g.Count()
}).ToList()
End Sub
Screenshot