Пример #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            OdbcConnection myConn = new OdbcConnection(connectionString);

            myConn.Open();
            string      mySelectQuery = "select * from Employee";
            OdbcCommand command       = new OdbcCommand(mySelectQuery, myConn);

            if (!Page.IsPostBack)
            {
                ListViewEmployees.DataSource = command.ExecuteReader();
                ListViewEmployees.DataBind();
            }
            myConn.Close();
        }
Пример #2
0
        private void populateListView()
        {
            OdbcConnection myConn = new OdbcConnection(connectionString);

            myConn.Open();
            string      mySelectQuery = "select * from Employee";
            OdbcCommand command       = new OdbcCommand(mySelectQuery, myConn);

            if (!Page.IsPostBack)
            {
                ListViewEmployees.DataSource = command.ExecuteReader();
                ListViewEmployees.DataBind();
            }

            myConn.Close();
        }
Пример #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                NorthwindEntities context = new NorthwindEntities();
                var employees             = context.Employees.Select(x => new
                {
                    Id        = x.EmployeeID,
                    FirstName = x.FirstName,
                    LastName  = x.LastName,
                }).ToList();

                GridViewEmployees.DataSource = employees;
                GridViewEmployees.DataBind();

                RepeaterEmployees.DataSource = context.Employees.ToList();
                RepeaterEmployees.DataBind();

                ListViewEmployees.DataSource = context.Employees.ToList();
                ListViewEmployees.DataBind();
            }
        }