Hi,
I am having a problem in understanding the below code.
it is a task regarding performiong crud operations with out using Data base with help of collections.
i am not able to understand How session is having the values despite not assaigning values to session.
Thank you in advance
class Employee
{
public int eid { get; set; }
public string name { get; set; }
public decimal salary { get; set; }
}
public partial class WebForm1 : System.Web.UI.Page
{
Employee obj = new Employee();
List el = new List();
protected void Page_Load(object sender, EventArgs e)
{
if(!Page.IsPostBack)
{
Session["emp"] = el;
}
el=(List)Session["emp"];
}
protected void Button1_Click(object sender, EventArgs e)
{
obj.eid = int.Parse(TextBox1.Text);
obj.name = TextBox2.Text;
obj.salary = Convert.ToDecimal(TextBox3.Text);
el = (List)Session["emp"];
el.Add(obj);
GridView1.DataSource = el.ToList();
GridView1.DataBind();
}
}

Jignesh KumarRank #91 · 22.9K reputationPosted Nov 22, 2018, 12:04 AM EST
Sreekanth ReddyRank #726 · 3.2K reputationPosted Nov 21, 2018, 9:54 PM EST
harry code125 reputationPosted Nov 21, 2018, 10:00 PM EST
Sreekanth ReddyRank #726 · 3.2K reputationPosted Nov 21, 2018, 10:23 PM EST
Jignesh KumarRank #91 · 22.9K reputationPosted Nov 21, 2018, 10:42 PM EST
harry code125 reputationPosted Nov 21, 2018, 10:56 PM EST
Laxmidhar SahooRank #383 · 6.6K reputationPosted Nov 21, 2018, 11:14 PM EST