TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
harry code
NA
124
22.8k
State Management
Nov 22 2018 1:00 AM
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<Employee> el = new List<Employee>();
protected void Page_Load(object sender, EventArgs e)
{
if(!Page.IsPostBack)
{
Session["emp"] = el;
}
el=(List<Employee>)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<Employee>)Session["emp"];
el.Add(obj);
GridView1.DataSource = el.ToList();
GridView1.DataBind();
}
}
Reply
Answers (
8
)
To Generate autoIncrement sequence in c#.
How to apply Best way for Logical Condition here.