0

I want to get the first 100 records from a DataSource. I have tried but it's not working.

 if (p_ForExport) {
            Session(this.gridData_Session) = ds.wsm_View_PurchaseOrderListForExport;
        } else {
            Session(this.gridData_Session) = ds.wsm_View_PurchaseOrderList;
        }
    divgrid.Visible = true;
        gridPOList.DataSource = Session(this.gridData_Session);
    gridPOList.Rows.Cast<System.Data.DataRow>().Take(100);
     //tried this but it's not working
        gridPOList.DataBind();
    }
piet.t
  • 11,718
  • 21
  • 43
  • 52
  • 1
    You could try *gridPOList.DataSource = Session(this.gridData_Session).Take(100);* – Trung Duong May 30 '17 at 04:17
  • 1
    Possible duplicate of [take top 10 or 20 rows from dynamic datatable](https://stackoverflow.com/questions/20718484/take-top-10-or-20-rows-from-dynamic-datatable) – Naveen Gogineni May 30 '17 at 04:20
  • @TrungDuong not working !! take is not coming after seesion –  May 30 '17 at 05:28
  • Because session variables are type of object, you must cast it before calling Take (cast it into type of your ds.wsm_View_PurchaseOrderList) – Trung Duong May 30 '17 at 05:36
  • Possible duplicate of [How to select top n rows from a datatable/dataview in ASP.NET](https://stackoverflow.com/questions/2787458/how-to-select-top-n-rows-from-a-datatable-dataview-in-asp-net) –  Jun 30 '17 at 16:26

0 Answers0