//Method used when the page is intially called and loaded private void Binding() { //Sets the datasource of the webpage's Gridview to the TableBase object's returned DataView DepartmentsGridView.DataSource = Base.BindGrid(); //Calls for the page to be updated and a postback DepartmentsGridView.DataBind(); }
//Method used when one of the events on the page is updating the table and query private void Binding(DataView view) { //Sets the datasource of the webpage's Gridview to the TableBase object's returned Dataview from event methods. DepartmentsGridView.DataSource = view; //Calls for the page to be updated and a postback DepartmentsGridView.DataBind(); }
protected void DepartmentsGridView_PageIndexChanging(object sender, GridViewPageEventArgs e) { DepartmentsGridView.DataSource = universityBL.GetDepartments(); DepartmentsGridView.DataBind(); DepartmentsGridView.PageIndex = e.NewPageIndex; DepartmentsGridView.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { DepartmentsGridView.Sort("Name", SortDirection.Ascending); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { DepartmentsGridView.DataSource = universityBL.GetDepartments(); DepartmentsGridView.DataBind(); } }
protected void lnkRemove_Click(object sender, EventArgs e) { LinkButton lnkRemove = (LinkButton)sender; int deptID = int.Parse(lnkRemove.CommandArgument); universityBL.DeleteDepartment(deptID); DepartmentsGridView.DataSource = universityBL.GetDepartments(); DepartmentsGridView.DataBind(); }
protected void get_department() { string sortString = Session["SortColumn"].ToString() + " " + Session["SortDirection"]; using (DefaultConnection db = new DefaultConnection()) { var department = (from alldepartments in db.Departments select alldepartments); DepartmentsGridView.DataSource = department.AsQueryable().OrderBy(sortString).ToList(); DepartmentsGridView.DataBind(); } }
/** * <summary> * This method gets the department data from the DB * </summary> * * @method GetDepartment * @returns {void} */ private void GetDepartment() { using (DefaultConnection db = new DefaultConnection()) { string SortString = Session["SortColumn"].ToString() + " " + Session["SortDirection"].ToString(); //write query var Departments = (from allDepartments in db.Departments select allDepartments).ToList(); DepartmentsGridView.DataSource = Departments.AsQueryable().OrderBy(SortString).ToList(); DepartmentsGridView.DataBind(); } }
}/** * <summary> * This method gets the departments data from the DB * </summary> * * @method GetDepartments * @returns {void} */ protected void GetDepartments() { //connect to EF using (DefaultConnection db = new DefaultConnection()) { //query the Departments table using EF and LINQ var Departments = (from allDepartments in db.Departments select allDepartments); //bind the results to the gridview DepartmentsGridView.DataSource = Departments.ToList(); DepartmentsGridView.DataBind(); } }
/** * <summary> * This method gets the department data from the database * </summary> * @method GetDepartments * @return {void} * */ protected void GetDepartments() { // Connect to EF using (DefaultConnection db = new DefaultConnection()) { string SortString = Session["SortColumn"].ToString() + " " + Session["SortDirection"].ToString(); // Query the departments table using EF and LINQ var Departments = (from allDepartments in db.Departments select allDepartments); // Bind results to gridview DepartmentsGridView.DataSource = Departments.AsQueryable().OrderBy(SortString).ToList(); DepartmentsGridView.DataBind(); } }
protected void GetDepartments() { //connect to the EF using (DefaultConnection db = new DefaultConnection()) { //query the students table using EF and LINQ var Departments = (from allDepartments in db.Departments select allDepartments); //sends the data to a list DepartmentsGridView.DataSource = Departments.ToList(); //binds the data to the grid DepartmentsGridView.DataBind(); } }
/** * <summary> * This method gets the student data from the DB * </summary> * * @method GetDepartments * @returns {void} */ protected void GetDepartments() { // connect to EF using (DefaultConn db = new DefaultConn()) { //create query string string SortString = Session["SortColumn"].ToString() + " " + Session["SortDirection"].ToString(); // query the Students Table using EF and LINQ var Departments = (from allDepartments in db.Departments select allDepartments); // bind the result to the GridView DepartmentsGridView.DataSource = Departments.AsQueryable().OrderBy(SortString).ToList(); DepartmentsGridView.DataBind(); } }
/** * <summary> * This method retrieves Departments from our db using EF * </summary> * @method GetDepartments() * @returns {void} */ protected void GetDepartments() { using (DefaultConnection db = new DefaultConnection()) { //query all departments from our ContosoModel var departments = (from allDepartments in db.Departments select new { allDepartments.DepartmentID, allDepartments.Name, allDepartments.Budget }); string sortString = Session["SortColumn"].ToString() + " " + Session["SortDirection"].ToString(); //bind the results to the gridview DepartmentsGridView.DataSource = departments.AsQueryable().OrderBy(sortString).ToList(); DepartmentsGridView.DataBind(); } }
protected void DepartmentsGridView_RowUpdating(object sender, GridViewUpdateEventArgs e) { string DepartmentID = ((Label)DepartmentsGridView.Rows[e.RowIndex] .FindControl("lblDepartmentID")).Text; string Name = ((TextBox)DepartmentsGridView.Rows[e.RowIndex] .FindControl("txtDepartmentName")).Text; DateTime startDate = ((Calendar)DepartmentsGridView.Rows[e.RowIndex] .FindControl("calendarStartDate")).SelectedDates[0]; Department dep = new Department(); dep.DepartmentID = int.Parse(DepartmentID); dep.Name = Name; dep.StartDate = startDate; universityBL.UpdateDepartment(dep); DepartmentsGridView.EditIndex = -1; DepartmentsGridView.DataSource = universityBL.GetDepartments(); DepartmentsGridView.DataBind(); }
void BindData() { List <ViewItem> items = GetItems(); if (items != null) { UPager.PageIndex = PageNumber; UPager.ItemCount = items.Count; UPager.UrlFormat = We7Helper.AddParamToUrl(Request.RawUrl, Keys.QRYSTR_PAGEINDEX, "{0}"); UPager.PrefixText = "共 " + UPager.MaxPages + " 页 · 第 " + UPager.PageIndex + " 页 · "; if (UPager.ItemCount <= 0) { DepartmentsGridView.DataSource = null; DepartmentsGridView.DataBind(); return; } else { DepartmentsGridView.DataSource = items.GetRange(UPager.Begin - 1, UPager.Count); DepartmentsGridView.DataBind(); } } }
protected void Page_Init(object sender, EventArgs e) { DepartmentsGridView.EnableDynamicData(typeof(Department)); }
//Експортування GridView private void ExportButton_Click(object sender, RoutedEventArgs e) { ComboBoxItem comboItem = (ComboBoxItem)ComboBox.SelectedItem; //Експортувати в документ PDF if (comboItem.Name != null && comboItem.Name.ToString() == "Pdf") { string extension = "pdf"; // SaveFileDialog dialog = new SaveFileDialog() { DefaultExt = extension, RestoreDirectory = true, Title = "Збереження", Filter = String.Format("Файл {1} (*.{0})|*.{0}|Всі файли (*.*)|*.*", extension, "Pdf"), FilterIndex = 1 }; if (dialog.ShowDialog() == true) { using (Stream stream = dialog.OpenFile()) { //параметри експорту DepartmentsGridView.ExportToPdf(stream, new GridViewPdfExportOptions() { ShowColumnHeaders = true, ShowColumnFooters = true, ShowGroupFooters = true, ExportDefaultStyles = true, PageOrientation = PageOrientation.Landscape }); //Повідомлення про успішне експортування MessageBox.Show("Експорт у файл Pdf виконано успішно!", "Повідомлення", MessageBoxButton.OK, MessageBoxImage.Information); } } } //Експортувати в документ Excel if (comboItem.Name != null && comboItem.Name.ToString() == "Xlsx") { string extension = "xlsx"; SaveFileDialog dialog = new SaveFileDialog() { DefaultExt = extension, Title = "Збереження", RestoreDirectory = true, Filter = String.Format("Файл {1} (*.{0})|*.{0}|Всі файли (*.*)|*.*", extension, "Excel"), FilterIndex = 1 }; if (dialog.ShowDialog() == true) { using (Stream stream = dialog.OpenFile()) { //параметри експорту DepartmentsGridView.ExportToXlsx(stream, new GridViewDocumentExportOptions() { ShowColumnFooters = true, ShowColumnHeaders = true, ShowGroupFooters = true, ExportDefaultStyles = true }); //Повідомлення про успішне експортування MessageBox.Show("Експорт у файл Excel виконано успішно!", "Повідомлення", MessageBoxButton.OK, MessageBoxImage.Information); } } } }
protected void SearchButton_Click(object sender, EventArgs e) { DepartmentsGridView.DataSource = universityBL.GetDepartmentsByName(SearchTextBox.Text); DepartmentsGridView.DataBind(); }
protected void DepartmentsGridView_RowEditing(object sender, GridViewEditEventArgs e) { DepartmentsGridView.EditIndex = e.NewEditIndex; DepartmentsGridView.DataSource = universityBL.GetDepartments(); DepartmentsGridView.DataBind(); }
protected void DepartmentsGridView_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e) { DepartmentsGridView.EditIndex = -1; DepartmentsGridView.DataSource = universityBL.GetDepartments(); DepartmentsGridView.DataBind(); }