Exemplo n.º 1
0
 protected void Page_Load(object sender, EventArgs e)
 {
     var context = new northwindEntities();
     var employeeDetails = context.Employees.ToList();
     this.employees.DataSource = employeeDetails;
     this.employees.DataBind();
 }
Exemplo n.º 2
0
 protected void Page_Load(object sender, EventArgs e)
 {
     var context = new northwindEntities();
     var id = int.Parse(Request.QueryString["id"]);
     var employeeDetails = context.Employees.Where(x => x.EmployeeID == id).ToList();
     this.details.DataSource = employeeDetails;
     this.details.DataBind();
 }
Exemplo n.º 3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            var context = new northwindEntities();
            var names = context.Employees.Select(
                x => new
                {
                    id = x.EmployeeID,
                    fullName = x.FirstName + " " + x.LastName
                }).ToList();

            if (!Page.IsPostBack)
            {
                this.employees.DataSource = names;
                this.employees.DataBind();
            }
        }
Exemplo n.º 4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            var context = new northwindEntities();
            var names = context.Employees
                .Select(
                x => new
                {
                    id = x.EmployeeID,
                    fullName = x.FirstName + " " + x.LastName
                })
                .ToList();

            //var first = context.Employees.Where(x => x.EmployeeID == 1).ToList();

            if (!Page.IsPostBack)
            {
                this.employees.DataSource = names;
                this.employees.DataBind();
                //this.details.DataSource = first;
                //this.details.DataBind();
            //}
            //else
            //{
                var parameter = Request.QueryString["id"];
                if (string.IsNullOrWhiteSpace(parameter))
                {
                    var employeeDetails = context.Employees.Where(x => x.EmployeeID == 1).ToList();
                    this.details.DataSource = employeeDetails;
                    this.details.DataBind();
                }
                else
                {
                    var id = int.Parse(Request.QueryString["id"]);
                    var employeeDetails = context.Employees.Where(x => x.EmployeeID == id).ToList();
                    this.details.DataSource = employeeDetails;
                    this.details.DataBind();
                }
            }
        }