I am new to all MVP stuff and slowly hugging it all. The problem I am facing is how to stay in accordance with the MVP methodology when populating GridViews (and ddls, but we will solve this later).
Is it possible to connect it directly to ObjectDataSourceID? To me, this seems wrong, because it circumvents all the separation of problems that MVP has made.
So, with that said, how do I do this? How to handle sorting (whether to send messages to handlers at the presentation level, if so, how does it look in the code)? Right now I have a GridView that does not sort. The code is below.
ListCustomers.aspx.cs:
public partial class ListCustomers : System.Web.UI.Page, IlistCustomer
{
protected void Page_Load(object sender, EventArgs e)
{
ListUserPresenter ListUser_P = new ListUserPresenter(this);
ListUser_P.PopulateList();
}
GridView IlistCustomer.UserGridView
{
get { return gvUsers; }
set { gvUsers = value; }
}
}
Interface (IlistCustomer.cs): is it a bad submission of the entire Gridview control?
public interface IlistCustomer
{
GridView UserGridView { set; get; }
}
Host (ListUserPresenter.cs):
public class ListUserPresenter
{
private IlistCustomer view_listCustomer;
private GridView gvListCustomers;
private DataTable objDT;
public ListUserPresenter( IlistCustomer view)
{
if (view == null)
throw new ArgumentNullException("ListCustomer View cannot be blank");
this.view_listCustomer = view;
}
public void PopulateList()
{
gvListCustomers = view_listCustomer.UserGridView;
CustomerBusiness CustomerBiz = new CustomerBusiness();
objDT = CustomerBiz.GetListCustomers();
gvListCustomers.DataSource = objDT;
gvListCustomers.DataBind();
}
}