using generic list instead of dataset

Nithadeepak
Posted by Nithadeepak under ASP.NET category on | Points: 40 | Views : 3226
Class UserBO
public class UserBO
{
string _userID;
string _firstName;
string _lastName;
string _userName;
string _password;
string _address;
string _city;
string _state;
long _zipcode;
long _phone;
string _email;
string _assignedTo;
string _userType;
string _status;

public string Status
{
get { return _status; }
set { _status = value; }
}
public string UserID
{
get
{
return _userID;
}
set
{
_userID = value;
}
}
public string FirstName
{
get
{
return _firstName;
}
set
{
_firstName = value;
}
}
public string LastName
{
get
{
return _lastName;
}
set
{
_lastName = value;
}
}
public string UserName
{
get
{
return _userName;
}
set
{
_userName = value;
}
}
public string Password
{
get
{
return _password;
}
set
{
_password = value;
}
}
public string Address
{
get
{
return _address;
}
set
{
_address = value;
}
}
public string City
{
get
{
return _city;
}
set
{
_city = value;
}
}
public string State
{
get
{
return _state;
}
set
{
_state = value;
}

}
public long Zipcode
{
get
{
return _zipcode;
}
set
{
_zipcode = value;
}
}
public long Phone
{
get
{
return _phone;
}
set
{
_phone = value;
}
}
public string Email
{
get
{
return _email;
}
set
{
_email = value;
}
}
public string AssignedTo
{
get
{
return _assignedTo;
}
set
{
_assignedTo = value;
}
}
public string UserType
{
get
{
return _userType;
}
set
{
_userType = value;
}
}
}




Data Access Layer
 public List<UserBO> SelectSupervisor()
{
SqlDataReader dr = SqlHelper.ExecuteReader(AppConfiguration.Connection, CommandType.StoredProcedure, Constants.SelectSupervisor);
List<UserBO> lst = new List<UserBO>();

while (dr.Read())
{
UserBO bo = new UserBO();

bo.UserID = dr["UserID"].ToString();
bo.FirstName = dr["FirstName"].ToString();
bo.LastName = dr["LastName"].ToString();
bo.UserName = dr["UserName"].ToString(); ;
bo.Password = dr["Password"].ToString();
bo.Address = dr["Address"].ToString();
bo.City = dr["City"].ToString();
bo.State = dr["State"].ToString();
bo.Zipcode = Convert.ToInt32(dr["Zipcode"]);
bo.Phone = Convert.ToInt64(dr["Phone"]);
bo.Email = dr["Email"].ToString();
bo.Status = dr["Status"].ToString();
lst.Add(bo);
}
return lst;
}


In UI
 List<UserBO> lst = new List<UserBO>();
lst = db.SelectSupervisor();
grdSupervisor.DataSource = lst;
grdSupervisor.DataBind();

Comments or Responses

Login to post response