H
hazz
The data access layer below returns, well, a mess as you can see on the last
line of this posting. What is the best way to return customer objects via a
datareader from the data layer into my view and bind them to a datagrid
using BindingList. I am in need of an epiphany here. Thank you. -Greg
******************BIND ARRAY OF CUSTOMER OBJECTS TO DATAGRID
************************
private Customer[] c;
c = BankTellerDataAccess.SqlHelper.ExecuteNonQuery();
BindingSource bs = new BindingSource();
BindingList<Customer> bList = new BindingList<Customer>();
// Fill bList with Customers
for (int i = 1; i <= 100; i++)
{
bList.Add(new Customer(c.ID, c.FirstName, c.LastName, c.Address1,);
}
bs.DataSource = bList;
dataGridView1.DataSource = bs;
******************FROM DATA ACCESS LAYER ************************
ArrayList arr = new ArrayList();
---datareader sets ID, FirstName, variables to values from database)
Customer o = new Customer(ID,FirstName, LastName, Address1);
arr.Add(o);
return (Customer[])arr.ToArray(typeof(Customer));
line of this posting. What is the best way to return customer objects via a
datareader from the data layer into my view and bind them to a datagrid
using BindingList. I am in need of an epiphany here. Thank you. -Greg
******************BIND ARRAY OF CUSTOMER OBJECTS TO DATAGRID
************************
private Customer[] c;
c = BankTellerDataAccess.SqlHelper.ExecuteNonQuery();
BindingSource bs = new BindingSource();
BindingList<Customer> bList = new BindingList<Customer>();
// Fill bList with Customers
for (int i = 1; i <= 100; i++)
{
bList.Add(new Customer(c.ID, c.FirstName, c.LastName, c.Address1,);
}
bs.DataSource = bList;
dataGridView1.DataSource = bs;
******************FROM DATA ACCESS LAYER ************************
ArrayList arr = new ArrayList();
---datareader sets ID, FirstName, variables to values from database)
Customer o = new Customer(ID,FirstName, LastName, Address1);
arr.Add(o);
return (Customer[])arr.ToArray(typeof(Customer));