//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.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 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(); }