/// <summary> /// Called after user click edit control on page /// Disable add button when editing a row /// </summary> /// <param name="sender">Sender</param> /// <param name="e">GridView Edit Event Arguments</param> protected virtual void GridView_RowEditing(object sender, GridViewEditEventArgs e) { //Remembering the DataKey of the row that is being changed to edit mode //so that if the order of items in grid changes correct row can be identifed dataKey = this.DataKeys[e.NewEditIndex][0]; this.hideButtons(); GetUpdatePanel.Update(); }
/// <summary> /// Called when user select cancel button on editable row; /// reenable add button when done editing row /// </summary> /// <param name="sender">Sender</param> /// <param name="e">GridView Cancel Edit Event Arguments</param> protected void GridView_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e) { this.showButtons(); if (this.ShowFooter == true) { this.ShowFooter = false; } GetUpdatePanel.Update(); }
/// <summary> /// Call after database has been updated, /// reenable add button when done editing row /// </summary> /// <param name="sender">Sender</param> /// <param name="e">Grid View Updated Event</param> protected void GridView_RowUpdated(object sender, GridViewUpdatedEventArgs e) { if (e.AffectedRows == 0) { e.KeepInEditMode = true; } else { this.showButtons(); } GetUpdatePanel.Update(); }
void TPMSFormView_ItemInserted(object sender, FormViewInsertedEventArgs e) { StringBuilder errorMessage = new StringBuilder(); Exception ex = e.Exception; if (ex != null) { if (!(ex is ApplicationException)) { while (ex != null) { ; } ErrorLabel.Text = errorMessage.ToString(); } e.ExceptionHandled = true; e.KeepInInsertMode = true; } GetUpdatePanel.Update(); }
void TPMSGridView_PreRender(object sender, EventArgs e) { //Disable buttons if GridView is disabed if (!this.Enabled) { hideButtons(); } else { if ((dataKey != null) && (this.EditIndex != -1)) { this.EditIndex = editIndexUsingDataKey; } //Set Focus to footer row if it is visible if ((this.FooterRow != null) && (this.FooterRow.Visible == true)) { //If Ajax is used on page then following //line of code will properly set focus to footer row if (AjaxEnabledPage) { ScriptManager.GetCurrent(this.Page).SetFocus(FooterRow); } else { Page.SetFocus(FooterRow); } //Because Footer Row is visible gridview is in insert mode, so hiding AddButtons hideButtons(); // Put header below datacontrols in footer row; if (AddHeaderToFooter) { for (int i = 0; i < this.Columns.Count; i++) { string header = HeaderRow.Cells[i].Text; if (header != null && header != string.Empty && header != " ") { Label label = new Label(); label.Text = "<center>" + header + "</center>"; label.ID = "label00" + i.ToString(); label.BackColor = System.Drawing.Color.Black; label.ForeColor = System.Drawing.Color.White; label.Width = Unit.Percentage(100.0); label.Font.Bold = true; label.Font.Name = "verdana"; FooterRow.Cells[i].Controls.Add(label); } } } } else if (this.EditIndex > -1) { if (AjaxEnabledPage) { ScriptManager.GetCurrent(this.Page).SetFocus(this.Rows[this.EditIndex]); } else { Page.SetFocus(this.Rows[this.EditIndex]); } } else if ((this.rowIndex != -1) && (this.Rows.Count > 0)) { //Set Focus to the row that raised the post back event if ((this.rowIndex < this.Rows.Count) && ((this.Rows[this.rowIndex].RowState == DataControlRowState.Edit) || (this.rowIndex > 0))) { if (AjaxEnabledPage) { ScriptManager.GetCurrent(this.Page).SetFocus(this.Rows[this.rowIndex]); } else { Page.SetFocus(this.Rows[this.rowIndex]); } } } if (((this.FooterRow == null) || (this.FooterRow.Visible == false)) && (this.EditIndex < 0)) { showButtons(); } } GetUpdatePanel.Update(); }