i am using dataview and with it's skip and take methods, that will take 5 rows and skip some rows according to the page number and page size.
//creating a dataview object and assigning table[0]
dv = new DataView(ds.Tables[0]);
and next line in which i am facing error is:
dv=(DataView)dv.Cast<System.Data.DataView>().Skip((pageNum-1)*pageSize).Take(5);
At above line error occur is:
Unable to cast object of type '<TakeIterator>d__3a`1[System.Data.DataView]' to type 'System.Data.DataView'.
needs help. thanx.
It works a little bit different, you can do the following:
var dt = ds.Tables[0];
dt = dt.AsEnumerable().Skip((pageNum - 1) * pageSize).Take(5).CopyToDataTable();
var dv = new DataView(dt);
GridView1.DataSource = dv;
GridView1.DataBind();
Not forget the "using System.Data;" and if you have time look for LINQ...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With