gjshah7254
7/24/2016 - 10:37 PM

Split or copy dataset into multiple dataset

Split or copy dataset into multiple dataset

DataSet dsMain = CustomCacheHelper.GetStorysDataSet();

        var dsOdd = new DataSet();
        dsOdd = dsMain.Copy();

        var dsEven = new DataSet();
        dsEven = dsMain.Copy();

        int rows = dsMain.Tables[0].Rows.Count-1;

        if (dsMain.Tables[0].Rows.Count == dsOdd.Tables[0].Rows.Count)//only go inside this once
        {
            for (int i = 0; i <= rows; i++)
            {
                if (!IsOdd(i))
                {
                    dsEven.Tables[0].Rows.RemoveAt(rows - i);
                }
                else
                {
                    dsOdd.Tables[0].Rows.RemoveAt(rows - i);
                }
            }
        }