Reputation: 969
I would like to pass a datatable to the DataAccessLayer from aspx.cs page. DAL is another project and CountryDal is a class file in it. Unable to do it using the session object. What is the proper way to acheive this.
ASPX.CS
private countryDAL objDAL = new CountryDAL();
protected void btnSave_Click(object sender, EventArgs e)
{
//code...
Session["tbl"] = dt; //dt is a datatable with some data
objDAL.SaveTable();
}
DAL
public void SaveTable()
{
DataTable dtSave = (DataTable)Session["tbl"];
//code.....
}
Upvotes: 1
Views: 1470
Reputation: 67928
Inject it into the method:
public void SaveTable(DataTable dtSave)
so then, when you call it, just do this:
objDAL.SaveTable(dt);
and you can get rid of this line:
Session["tbl"] = dt;
Upvotes: 2