Hi
I have a list like List<vahed>. this list fill from vahed class.when i want to bind list into gridview ,I store it in Session. but when this list bind to grid view,data is empty.
my code:
//class vahed
public List<Vahed> SelectAll()
{
Vahed V = new Vahed();
string command = "SELECT FEMAIN.GHAR, VAHED.KARBARINUM, FEMAIN.KOL_AYAN, FEMAIN.KOL_ARSE, FEMAIN.MOFID, FEMAIN.AB_ENSH, FEMAIN.FA_ENSH, FEMAIN.AB_TAFK,FEMAIN.FA_TAFk FROM FEMAIN INNER JOIN VAHED ON FEMAIN.ID_FEMAIN = VAHED.ID_FEMAIN ";
SqlCommand sc = new SqlCommand(command, new SqlConnection(GlobalFunction.Function.GetConnectionString()));
sc.Connection.Open();
SqlDataReader dr = sc.ExecuteReader();
List<Vahed> LV = new List<Vahed>();
using(dr)
{
while (dr.Read())
{
V.KARBARINUM=dr["KARBARINUM"].ToString();
V.FeObj.Ghar=Convert.ToInt32(dr["GHAR"]);
V.FeObj.Kol_Ayan=Convert.ToInt32(dr["KOL_AYAN"]);
V.FeObj.Kol_Arse=Convert.ToInt32(dr["KOL_ARSE"]);
V.FeObj.Mofid=Convert.ToInt32(dr["MOFID"]);
V.FeObj.Ab_Ensh=dr["AB_ENSH"].ToString();
V.FeObj.Fa_Ensh=dr["FA_ENSH"].ToString();
V.FeObj.Ab_Tafk=dr["AB_TAFK"].ToString();
V.FeObj.Fa_Tafk=dr["FA_TAFK"].ToString();
LV.Add(V);
}
}
sc.Connection.Close();
return LV;
}
// my webpage
Session["SessFemain"] = v.SelectAll();
GridFemain.DataSource = (List<BussinessLayer.Vahed>)Session["SessFemain"];
GridFemain.AllowPaging = true;
GridFemain.PageSize = 5;
GridFemain.DataBind();