Пример #1
0
        private void BindGrid()
        {
            try
            {
                DataTable dt = new DataTable();
                dt.Columns.AddRange(new DataColumn[2] {
                    new DataColumn("Id"), new DataColumn("Name")
                });

                db.GetAllBooks().ForEach(x => dt.Rows.Add(x.ID, x.Name));

                GridView1.DataSource = dt;
                GridView1.DataBind();
            }
            catch (Exception ex)
            {
                exceptionLable.Text = ex.Message;
            }
        }