Hi guys,
Let me start by saying that this product is awesome. Love the new esdatasource control. I know about the paging and sorting issue with Sql 2005.
Scott.Schecter:You have to set the properties AutoSorting="False" AutoPaging="False" on your esDataSource control. You then have to roll your own sorting and paging if you require them. The must also now call your .Load() explicitly in your esSelectEvent.
Do you have any examples on how to best implement sorting and paging using es code and syntax.
Thanks for your help.
Cristian
Regards, Scott Schecter EntitySpaces | Blog | Twitter
Samples are below
http://community.entityspaces.net/forums/thread/3296.aspx
http://community.entityspaces.net/forums/thread/3458.aspx
Hi Scott, Thanks for the samples, i have seen those before, it helped me quite a bit to get the rest of the functionality working. Right now, i'm looking at implementing some proper paging and sorting for sql 2000.
This is the code i was working with before but i really like the es way of coding and i'm still getting used to it.
public partial class cust_search : System.Web.UI.Page { private string GridViewSortDirection { get { return ViewState["SortDirection"] as string ?? "ASC"; } set { ViewState["SortDirection"] = value; } } private string GridViewSortExpression { get { return ViewState["SortExpression"] as string ?? string.Empty; } set { ViewState["SortExpression"] = value; } } protected void Page_Load(object sender, EventArgs e) { } DataTable BindData(string searchType, string whereClause, string searchCriteria) { ContactsCollection cc = new ContactsCollection(); //custom method in BLL DataTable newDt = cc.searchContact("customer", searchCriteria, searchType, whereClause); ViewState["gvResults_DataSource"] = newDt; return newDt; } protected void searchGrid_PageIndexChanging(object sender, GridViewPageEventArgs e) { searchGrid.DataSource = SortDataTable((DataTable)ViewState["gvResults_DataSource"], true); searchGrid.PageIndex = e.NewPageIndex; searchGrid.DataBind(); } protected void searchGrid_Sorting(object sender, GridViewSortEventArgs e) { GridViewSortExpression = e.SortExpression; int pageIndex = searchGrid.PageIndex; searchGrid.DataSource = SortDataTable((DataTable)ViewState["gvResults_DataSource"], false); searchGrid.DataBind(); searchGrid.PageIndex = pageIndex; } private string GetSortDirection() { switch (GridViewSortDirection) { case "ASC": GridViewSortDirection = "DESC"; break; case "DESC": GridViewSortDirection = "ASC"; break; } return GridViewSortDirection; } protected DataView SortDataTable(DataTable dataTable, bool isPageIndexChanging) { if (dataTable != null) { DataView dataView = new DataView(dataTable); if (GridViewSortExpression != string.Empty) { if (isPageIndexChanging) { dataView.Sort = string.Format("{0} {1}", GridViewSortExpression, GridViewSortDirection); } else { dataView.Sort = string.Format("{0} {1}", GridViewSortExpression, GetSortDirection()); } } return dataView; } else { return new DataView(); } } }
As you can see, it's quite an involved way of doing it and i was wondering if you got a better way using ES.
Thanks for all your help.