Try:
This Code Divide into half
I want to get the result like below
DataTable dt = new DataTable();
DataTable dt1 = new DataTable();
DataTable dt2 = new DataTable();
//Filling Data Table
dt = ob.Fill_DataTable("test");
//spliting Data Table
var totalRows = dt.Rows.Count;
var halfway = totalRows / 2;
var firstHalf = dt.AsEnumerable().Take(halfway).CopyToDataTable();
var secondHalf = dt.AsEnumerable().Skip(halfway).Take(totalRows - halfway).CopyToDataTable();
//Get Result
dt1 = firstHalf;
dt2 =secondHalf;
All Data
1 متر m 2 سانتی متر cm 3 لیتر Liter 4 کیلوگرم Kg
Data Table one (Odd Rows)
1 متر m
3 لیتر Liter
Data Table Two (Even Rows)
2 سانتی متر cm
4 کیلوگرم Kg
can it be done?
Comments
Post a Comment