http://forums.asp.net/p/1069129/1554769.aspx
I adapted the above post for my proof of concept. I have only tested selecting data, not editing data. here is what I have if anyone is interested.
using System;
using System.Collections;
using System.Web.UI.WebControls;
namespace My.Web.Utilities
{
public class GridViewMVPAdapter : IGridViewMVPAdapter
{
private IEnumerable data;
private int virtualItemCount;
private GridView underlyingControl;
public GridViewDomainModelControl(GridView gridView)
{
this.underlyingControl = gridView;
}
#region IGridViewMVPAdapterMembers
public int PageIndex
{
get { return this.underlyingControl.PageIndex; }
set
{
if (value < -1)
{
value = -1;
}
if (value > this.underlyingControl.PageCount)
{
value = this.underlyingControl.PageCount;
}
this.underlyingControl.PageIndex = value;
}
}
public void BindTo(IEnumerable data, int totalRecords)
{
this.data = data;
this.virtualItemCount = totalRecords;
ObjectDataSource ods = new ObjectDataSource();
ods.ObjectCreating += new ObjectDataSourceObjectEventHandler(ods_ObjectCreating);
ods.EnablePaging = this.underlyingControl.AllowPaging;
ods.TypeName = "My.Web.Utilities.IVirtualCountTableAdapter";
ods.SelectMethod = "GetData";
ods.SelectCountMethod = "VirtualItemCount";
ods.StartRowIndexParameterName = "startRow";
ods.MaximumRowsParameterName = "maxRows";
ods.EnableViewState = false;
this.underlyingControl.DataSource = ods;
this.underlyingControl.DataBind();
}
#endregion
private void ods_ObjectCreating(object sender, ObjectDataSourceEventArgs e)
{
e.ObjectInstance = new VirtualCountTableAdapter(this.data, this.virtualItemCount);
}
}
public class VirtualCountTableAdapter : IVirtualCountTableAdapter
{
private IEnumerable data;
private int virtualItemCount;
public VirtualCountTableAdapter(IEnumerable data, int virtualItemCount)
{
this.data = data;
this.virtualItemCount = virtualItemCount;
}
public int VirtualItemCount()
{
return this.virtualItemCount;
}
public IEnumerable GetData()
{
return this.data;
}
public IEnumerable GetData(int startRow, int maxRows)
{
return this.data;
}
}
interface IVirtualCountTableAdapter
{
IEnumerable GetData(int startRow, int maxRows);
IEnumerable GetData();
int VirtualItemCount();
}
}
Is this similar to how LLBLDataSource sets the page count?