Hi , I am writting a website using .net in some of my pages I need to use datagrid for showing some datas and for binding my data to datagrid I use object datasource something like below :
//this is
public class userData
{
private long userid = 0;
private string username = null;
private long amounts = 0;
private DateTime registerdate;
public long Userid
{
get { return userid; }
set { userid = value; }
}
public string Username
{
get { return username; }
set { username = value; }
}
public long Amounts
{
get { return amounts; }
set { amounts = value; }
}
public DateTime Registerdate
{
get { return registerdate; }
set
{ registerdate = value;}
}
}
//my businesshelper class
public class BusinessHelper
{
public BusinessHelper()
{
//
// TODO: Add constructor logic here
//
}
public ICollection GetusersAmount()
{
ArrayList list = new ArrayList();
DataSet1TableAdapters.userTableAdapter usert = new DataSet1TableAdapters.userTableAdapter();
DataSet1.userDataTable ud = usert.GetData();
foreach(DataSet1.userRow R in ud)
{
userData user = new userData();
user.Amounts = R.Amount;
user.Registerdate = R.registerdate;
user.Userid = R.userID;
user.Username = R.username ;
list.Add(user);
}
return list;
}
}
and then in my apsx file I put an objectdatasource and bind the select statement to the GetUsersAmount() and then bind obejctdatasource to my datagrid
but I think the way I've chosen is not efficient I just want to hear about your way of doing such these things.
regards.