views:

34

answers:

1

Hi All,

I am retrieving data from sql database. I want to split the records and binding it in three different grids. Everything is working fine before applying paging. I am getting The data source does not support server-side data paging. error

Code:

 DataTable  StoreDisplayTypeList = storeDisplayBL.GetStoreDisplayDetails();

        var specialBook = from myRow in StoreDisplayTypeList.AsEnumerable() where (string)myRow["StoreDisplayType"] == "Special Book" select myRow;
        var newRelease = from myRow in StoreDisplayTypeList.AsEnumerable() where (string)myRow["StoreDisplayType"] == "New Release" select myRow;
        var Seller = from myRow in StoreDisplayTypeList.AsEnumerable() where (string)myRow["StoreDisplayType"] == "Best Seller" select myRow;
        var featuredEdition = from myRow in StoreDisplayTypeList.AsEnumerable() where (string)myRow["StoreDisplayType"] == "Featured Edition" select myRow;         

        this.gvBestSeller.DataSource = Seller;
        this.gvBestSeller.DataBind();  // Error

        this.gvNewRelease.DataSource = newRelease;
        this.gvNewRelease.DataBind();  // Error

        this.gvSpecialBook.DataSource = specialBook;
        this.gvSpecialBook.DataBind();  // Error

        this.gvFeaturedREdition.DataSource = featuredEdition;
        this.gvFeaturedREdition.DataBind();  // Error
A: 

That is because you are using vars. You need to use a strongly-typed object such as a List<>.

public class Book
{
    public string _StoreDisplayType { get; set; }
    public string _title { get; set; }
}

var specialBook = from myRow in StoreDisplayTypeList.AsEnumerable() 
                  where (string)myRow["StoreDisplayType"] == "Special Book" 
                  select new Book{ 
                      _StoreDisplayType = myRow["StoreDisplayType"].ToString(), 
                      _title = myRow["Title"].ToString()
                  };      

this.gvSpecialBook.DataSource = specialBook.ToList();
this.gvSpecialBook.DataBind();
JumpingJezza
You're right, but just a clarification - var IS strongly typed, by the RHS - in which case .AsEnumerable was returning an IEnumerable result set (which isnt concrete of course).
RPM1984