protected void GridView1_RowUpdating(object sender, System.Web.UI.WebControls.GridViewUpdateEventArgs e) { //Finding the controls from Gridview for the row which is going to update Label id = GridView1.Rows[e.RowIndex].FindControl("lbl_ID") as Label; TextBox name = GridView1.Rows[e.RowIndex].FindControl("txt_Name") as TextBox; TextBox email = GridView1.Rows[e.RowIndex].FindControl("txt_Email") as TextBox; TextBox password = GridView1.Rows[e.RowIndex].FindControl("txt_Password") as TextBox; TextBox confirmpassword = GridView1.Rows[e.RowIndex].FindControl("txt_Confirm_Password") as TextBox; TextBox address = GridView1.Rows[e.RowIndex].FindControl("txt_Address") as TextBox; TextBox phoneno = GridView1.Rows[e.RowIndex].FindControl("txt_Phoneno") as TextBox; TextBox salary = GridView1.Rows[e.RowIndex].FindControl("txt_Salary") as TextBox; TextBox Gender = GridView1.Rows[e.RowIndex].FindControl("txt_Gender") as TextBox; conn.Open(); //updating the record SqlCommand cmd = new SqlCommand("Update tbl_Staff set Name='" + name.Text + "',Email='" + email.Text + "' ,Password='******' ,Confirm_Password='******' ,Address='" + address.Text + "' ,Phoneno='" + phoneno.Text + "' ,Gender= (select LookupID from tbl_Lookup where Value = '" + Gender.Text + "') ,Salary='" + salary.Text + "' where StaffID=" + Convert.ToInt32(id.Text), conn); cmd.ExecuteNonQuery(); conn.Close(); //Setting the EditIndex property to -1 to cancel the Edit mode in Gridview GridView1.EditIndex = -1; //Call ShowData method for displaying updated data ShowData(); }
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e) { SqlConnection con = new SqlConnection(str); con.Open(); GridViewRow row = (GridViewRow)GridView1.Rows[e.RowIndex]; Label l1 = (Label)row.FindControl("lblid"); int id = Convert.ToInt32(l1.Text); TextBox txtbox = (TextBox)row.FindControl("txtname"); String name = txtbox.Text; GridView1.EditIndex = -1; SqlCommand cmd = new SqlCommand("update advisor set aname=@name where aid=@id", con); cmd.Parameters.AddWithValue("@id", id); cmd.Parameters.AddWithValue("@name", name); cmd.ExecuteNonQuery(); con.Close(); bind(); }
protected void gvDSDiary_RowUpdating(object sender, GridViewUpdateEventArgs e) { GridViewRow row = gvDSDiary.Rows[e.RowIndex]; //drdto = new DiaryDTO(); int madiary = Int32.Parse(gvDSDiary.DataKeys[e.RowIndex].Value.ToString()); //drdto.MaDiary = madiary; //TextBox thamchieu = row.Cells[1].Controls[0] as TextBox; //drdto.MaClaim = thamchieu.Text; //TextBox ngay = row.Cells[2].Controls[0] as TextBox; //drdto.Ngay = DateTime.Parse(ngay.Text); //TextBox diengiai = row.Cells[3].Controls[0] as TextBox; //drdto.DienGiai = diengiai.Text; //TextBox sogio = row.Cells[4].Controls[0] as TextBox; //drdto.SoGio = float.Parse(sogio.Text); //TextBox batdau = row.Cells[5].Controls[0] as TextBox; //drdto.NgayGioBatDau = DateTime.Parse(batdau.Text); //TextBox ketthuc = row.Cells[6].Controls[0] as TextBox; //drdto.NgayGioKetThuc = DateTime.Parse(ketthuc.Text); TextBox ketqua = row.Cells[7].Controls[0] as TextBox; string result=ketqua.Text; if (result == null) result = "Will be update late!"; bool cn = drdao.updateResult(madiary,result); if (cn == true) { e.Cancel = true; gvDSDiary.EditIndex = -1; loadDiaryAll(); } }
protected void GridViewContacts_RowUpdating(object sender, System.Web.UI.WebControls.GridViewUpdateEventArgs e) { if (e.NewValues["PersonneCivilite"] == null) { e.NewValues["PersonneCivilite"] = ""; } if (e.NewValues["PersonneNom"] == null) { e.NewValues["PersonneNom"] = e.OldValues["PersonneNom"]; } if (e.NewValues["PersonnePrenom"] == null) { e.NewValues["PersonnePrenom"] = e.OldValues["PersonnePrenom"]; } if (e.NewValues["PersonneSociete"] == null) { e.NewValues["PersonneSociete"] = string.Empty; } SqlDataSourcePersonne.SelectCommand = SelectCommand(); GridViewContacts.DataBind(); }
protected void savedSearchResultSetGrid_RowUpdating(object sender, System.Web.UI.WebControls.GridViewUpdateEventArgs e) { Logging.Logger.Instance.Info(String.Format("Row Updating")); DataControlFieldCell cell; int tableCellsCount = savedSearchResultSetGrid.Rows[e.RowIndex].Cells.Count; for (int i = 0; i < tableCellsCount; i++) { cell = savedSearchResultSetGrid.Rows[e.RowIndex].Cells[i] as DataControlFieldCell; cell.ContainingField.ExtractValuesFromCell( e.Keys, cell, DataControlRowState.Normal, true); } for (int i = 0; i < tableCellsCount; i++) { cell = savedSearchResultSetGrid.Rows[e.RowIndex].Cells[i] as DataControlFieldCell; cell.ContainingField.ExtractValuesFromCell( e.NewValues, cell, DataControlRowState.Edit, true); } UpdateSearchResultSet(e.NewValues); savedSearchResultSetGrid.EditIndex = -1; PopulateSavedSearchResultSetsGrid(); }
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e) { try { int id = Convert.ToInt32((string) GridView1.DataKeys[e.RowIndex].Values[0].ToString()); string SlnName = ((TextBox)GridView1.Rows[e.RowIndex].FindControl("SlnName")).Text; string Namespace = ((TextBox)GridView1.Rows[e.RowIndex].FindControl("Namespace")).Text; string RefNamespace = ((TextBox)GridView1.Rows[e.RowIndex].FindControl("RefNamespace")).Text; string url = ((TextBox)GridView1.Rows[e.RowIndex].FindControl("Url")).Text; string gameid = ((TextBox)GridView1.Rows[e.RowIndex].FindControl("gameid")).Text; SolutionModel mode = new SolutionModel(); mode.SlnID = id; mode.SlnName = SlnName; mode.Namespace = Namespace; mode.RefNamespace = RefNamespace; mode.Url = url; mode.GameID = Convert.ToInt32(gameid); if (DbDataLoader.Update(mode)) { GridView1.EditIndex = -1; BindData(); } } catch (Exception erro) { Response.Write("错误信息:" + erro.Message); } }
protected void GridView1_RowUpdating(object sender, System.Web.UI.WebControls.GridViewUpdateEventArgs e) { SqlConnection con = new SqlConnection("Data Source=.\\SQLExpress1;Initial Catalog=studentslog;Integrated Security=True"); con.Open(); //Finding the controls from Gridview for the row which is going to update //********** Label dept_name = GridView1.Rows[e.RowIndex].FindControl("lbl_Name") as Label; // Label dept_name = GridView1.Rows[e.RowIndex].FindControl("lbl_Names") as Label; Label admissn_no = GridView1.Rows[e.RowIndex].FindControl("lbl_admissn_no") as Label; TextBox stud_name = GridView1.Rows[e.RowIndex].FindControl("txt_studName") as TextBox; TextBox cors_name = GridView1.Rows[e.RowIndex].FindControl("txt_cors") as TextBox; // TextBox batch_name = GridView1.Rows[e.RowIndex].FindControl("txt_batch") as TextBox; // TextBox city = GridView1.Rows[e.RowIndex].FindControl("txt_City") tas TextBox; string ds = Convert.ToString(stud_name.Text); //updating the record SqlCommand cmd = new SqlCommand("Update tbl_student set stud_name = '" + stud_name.Text + "',cors_name='" + cors_name.Text + "' where admissn_no =" + Convert.ToInt32(admissn_no.Text), con); cmd.ExecuteNonQuery(); con.Close(); //Setting the EditIndex property to -1 to cancel the Edit mode in Gridview GridView1.EditIndex = -1; //Call ShowData method for displaying updated data ShowData(); }
protected void gvAppointments_RowUpdating(Object sender, System.Web.UI.WebControls.GridViewUpdateEventArgs e) { /*int rowIndex = e.RowIndex; * * string day = gvAppointments.Rows[e.RowIndex].Cells[0].Text; * string time = gvAppointments.Rows[e.RowIndex].Cells[1].Text; * string firstName = ((TextBox)(gvAppointments.Rows[e.RowIndex].Cells[2].Controls[0])).Text; * string lastName = ((TextBox)(gvAppointments.Rows[e.RowIndex].Cells[3].Controls[0])).Text; * string doctor = gvAppointments.Rows[e.RowIndex].Cells[4].Text; * //string id = gvAppointments.Rows[e.RowIndex].Cells[5].Text; * int id = Convert.ToInt32(gvAppointments.DataKeys[e.RowIndex]["Id"]); * * if (firstName == "" || lastName == "") * { * gvAppointments.EditIndex = -1; * } * else * { * SqlCommand objUpdate = new SqlCommand(); * objCommand.CommandType = CommandType.StoredProcedure; * objCommand.CommandText = "updateAppointment"; * * objCommand.Parameters.AddWithValue("@day", day); * objCommand.Parameters.AddWithValue("@time", time); * objCommand.Parameters.AddWithValue("@firstName", firstName); * objCommand.Parameters.AddWithValue("@lastName", lastName); * objCommand.Parameters.AddWithValue("@doctor", doctor); * objCommand.Parameters.AddWithValue("@id", id); * * DataSet myDS = objDB.GetDataSetUsingCmdObj(objCommand); * * gvAppointments.EditIndex = -1; * ShowAppointments(); * }*/ }
protected void GridView2_RowUpdating(object sender, System.Web.UI.WebControls.GridViewUpdateEventArgs e) { //Finding the controls from Gridview for the row which is going to update Label DegreeName = GridView2.Rows[e.RowIndex].FindControl("lbl_DegreeName") as Label; Label University = GridView2.Rows[e.RowIndex].FindControl("lbl_University") as Label; TextBox RegistrationDate = GridView2.Rows[e.RowIndex].FindControl("txt_RegistrationDate") as TextBox; TextBox SubmissionDate = GridView2.Rows[e.RowIndex].FindControl("txt_SubmissionDate") as TextBox; Label RegistrationNo = GridView2.Rows[e.RowIndex].FindControl("lbl_RegistrationNo") as Label; TextBox ThesisTitle = GridView2.Rows[e.RowIndex].FindControl("txt_ThesisTitle") as TextBox; con = new MySqlConnection(cs); con.Open(); //updating the record MySqlCommand cmd = con.CreateCommand(); cmd.CommandText = "Update edu_doctorate set RegistrationDate= @RegistrationDate, SubmissionDate= @SubmissionDate, ThesisTitle= @ThesisTitle where User_ID=@user_id and RegistrationNo=@RegistrationNo and University= @University"; cmd.Parameters.AddWithValue("@DegreeName", DegreeName.Text); cmd.Parameters.AddWithValue("@University", University.Text); cmd.Parameters.AddWithValue("@RegistrationDate", RegistrationDate.Text); cmd.Parameters.AddWithValue("@SubmissionDate", SubmissionDate.Text); cmd.Parameters.AddWithValue("@ThesisTitle", ThesisTitle.Text); cmd.Parameters.AddWithValue("@RegistrationNo", RegistrationNo.Text); cmd.Parameters.AddWithValue("@user_id", user_id); cmd.ExecuteNonQuery(); con.Close(); //Setting the EditIndex property to -1 to cancel the Edit mode in Gridview GridView2.EditIndex = -1; //Call ShowData_1 method for displaying updated data ShowData_2(); }
//The RowUpdating event is raised when a row's Update button is clicked, //but before the GridView control updates the row. //This enables you to provide an event-handling //method that performs a custom routine, such as canceling the update operation, whenever this event occurs. protected void GridView1_RowUpdating(object sender, System.Web.UI.WebControls.GridViewUpdateEventArgs e) { //Simdilik burda kalsin, ileride lazim olabilir..@mertbesirli // Label id = GridView1.Rows[e.RowIndex].FindControl("lbl_ID") as Label; //Finding the controls from Gridview for the row which is going to update TextBox name = GridView1.Rows[e.RowIndex].FindControl("nameTextBox") as TextBox; TextBox url = GridView1.Rows[e.RowIndex].FindControl("urlTextBox") as TextBox; TextBox phonecode = GridView1.Rows[e.RowIndex].FindControl("phoneCodeTextBox") as TextBox; TextBox phonenumber = GridView1.Rows[e.RowIndex].FindControl("phoneNumberTextBox") as TextBox; TextBox iban = GridView1.Rows[e.RowIndex].FindControl("ibanTextBox") as TextBox; TextBox desc = GridView1.Rows[e.RowIndex].FindControl("descriptionTextBox") as TextBox; TextBox taxadmin = GridView1.Rows[e.RowIndex].FindControl("taxAdminTextBox") as TextBox; TextBox taxnumber = GridView1.Rows[e.RowIndex].FindControl("taxNumberText") as TextBox; con.Open(); //Update to databese CompanyInfo SqlCommand cmd = new SqlCommand("Update CompanyInfo set Name='" + name.Text + "',SiteURL='" + url.Text + "',PhoneContryCode='" + phonecode.Text + "',PhoneNumber='" + phonenumber.Text + "',IBAN='" + iban.Text + "',Company_Description='" + desc.Text + "',Tax_Admin='" + taxadmin.Text + "',Tax_number='" + taxnumber.Text + "'", con); cmd.ExecuteNonQuery(); con.Close(); //Setting the EditIndex property to -1 to cancel the Edit mode in Gridview GridView1.EditIndex = -1; //Call ShowData method for displaying updated data ShowData(); }
protected void OnRowUpdating(object sender, System.Web.UI.WebControls.GridViewUpdateEventArgs e) { string constr = ConfigurationManager.ConnectionStrings["dc1"].ConnectionString; string SID = GridView1.DataKeys[e.RowIndex].Value.ToString(); Label SID1 = (Label)GridView1.Rows[e.RowIndex].FindControl("lblName"); TextBox txtc = (TextBox)GridView1.Rows[e.RowIndex].FindControl("txtclass"); TextBox txtn = (TextBox)GridView1.Rows[e.RowIndex].FindControl("txtname"); SqlConnection conn = new SqlConnection(constr); SqlCommand cmd = new SqlCommand("Update slog set cl='" + txtc.Text + "',fname='" + txtn.Text + "' where sid='" + SID1 + "'", conn); conn.Open(); cmd.ExecuteNonQuery(); conn.Close(); GridView1.EditIndex = -1; this.BindGrid(); }
protected void GridView1_RowUpdating(object sender, System.Web.UI.WebControls.GridViewUpdateEventArgs e) { //Finding the controls from Gridview for the row which is going to update Label id = GridView1.Rows[e.RowIndex].FindControl("lbl_ID") as Label; TextBox fName = GridView1.Rows[e.RowIndex].FindControl("txt_fName") as TextBox; TextBox lName = GridView1.Rows[e.RowIndex].FindControl("txt_lName") as TextBox; TextBox email = GridView1.Rows[e.RowIndex].FindControl("txt_email") as TextBox; con = conn; //con.Open(); //updating the record SqlCommand cmd = new SqlCommand("Update [dbo].[Employee] set [FirstName]= @firstName ,[LastName]= @lastName ,[Email]= @email where EmployeeID=" + Convert.ToInt32(id.Text), con); cmd.Parameters.AddWithValue("@firstName", fName.Text); cmd.Parameters.AddWithValue("@lastName", lName.Text); cmd.Parameters.AddWithValue("@email", email.Text); cmd.ExecuteNonQuery(); con.Close(); //Setting the EditIndex property to -1 to cancel the Edit mode in Gridview GridView1.EditIndex = -1; //Call ShowData method for displaying updated data ShowData(); }
protected void gvRepresentative_RowUpdating(Object sender, System.Web.UI.WebControls.GridViewUpdateEventArgs e) { int rowIndex = e.RowIndex; TextBox TBox; Label label; label = (Label)gvRepresentative.Rows[rowIndex].FindControl("lblName"); string Name = label.Text; TBox = (TextBox)gvRepresentative.Rows[rowIndex].FindControl("txtCity"); string City = TBox.Text; TBox = (TextBox)gvRepresentative.Rows[rowIndex].FindControl("txtState"); string State = TBox.Text; DropDownList ddl; ddl = (DropDownList)gvRepresentative.Rows[rowIndex].FindControl("ddlType"); int type = int.Parse(ddl.SelectedValue); gvRepresentative.EditIndex = -1; newUpdate.UpdateRestaurant(Name, type, State, City); gvRepresentative.DataSource = newData.ResWithType(); gvRepresentative.DataBind(); }
protected void GridView1_RowUpdating(object sender, System.Web.UI.WebControls.GridViewUpdateEventArgs e) { //Finding the controls from Gridview for the row which is going to update Label id = GridView1.Rows[e.RowIndex].FindControl("lbl_StudentNum") as Label; TextBox Sname = GridView1.Rows[e.RowIndex].FindControl("txt_StudentName") as TextBox; TextBox Sfaculty = GridView1.Rows[e.RowIndex].FindControl("txt_StudentFaculty") as TextBox; TextBox Sdepartmant = GridView1.Rows[e.RowIndex].FindControl("txt_StudentDepartmant") as TextBox; TextBox Sadress = GridView1.Rows[e.RowIndex].FindControl("txt_StudentAdress") as TextBox; TextBox SphoneNum = GridView1.Rows[e.RowIndex].FindControl("txt_StudentPhone") as TextBox; TextBox SregDate = GridView1.Rows[e.RowIndex].FindControl("txt_StudentRegDate") as TextBox; con = new SqlConnection(WebConfigurationManager.ConnectionStrings["AkinSoftConnect"].ConnectionString); con.Open(); //updating the record SqlCommand cmd = new SqlCommand("Update Student set StudentName='" + Sname.Text + "',StudentFaculty='" + Sfaculty.Text + "',StudentDepartmant='" + Sdepartmant.Text + "',StudentAdress='" + Sadress.Text + "',StudentPhoneNum='" + SphoneNum.Text + "' where StudentNum= + '" + id.Text + "'", con); cmd.ExecuteNonQuery(); con.Close(); //Setting the EditIndex property to -1 to cancel the Edit mode in Gridview GridView1.EditIndex = -1; //Call ShowData method for displaying updated data ShowData(); }
protected void gvReservation_RowUpdating(Object sender, System.Web.UI.WebControls.GridViewUpdateEventArgs e) { int rowIndex = e.RowIndex; int id = int.Parse(gvReservation.Rows[rowIndex].Cells[0].Text); TextBox TBox; TBox = (TextBox)gvReservation.Rows[rowIndex].Cells[2].Controls[0]; String name = TBox.Text; TBox = (TextBox)gvReservation.Rows[rowIndex].Cells[3].Controls[0]; String date = TBox.Text; TBox = (TextBox)gvReservation.Rows[rowIndex].Cells[4].Controls[0]; String time = TBox.Text; TBox = (TextBox)gvReservation.Rows[rowIndex].Cells[5].Controls[0]; int table = int.Parse(TBox.Text); objCommand.CommandType = CommandType.StoredProcedure; objCommand.CommandText = "UpdateReservation"; objCommand.Parameters.AddWithValue("@theName", name); objCommand.Parameters.AddWithValue("@theDate", date); objCommand.Parameters.AddWithValue("@theTime", time); objCommand.Parameters.AddWithValue("@theTable", table); objCommand.Parameters.AddWithValue("@theID", id); objDB.DoUpdateUsingCmdObj(objCommand); gvReservation.EditIndex = -1; ShowReservation(); }
protected void GridView1_RowUpdating(object sender, System.Web.UI.WebControls.GridViewUpdateEventArgs e) { //Finding the controls from Gridview for the row which is going to update Label DegreeType = GridView1.Rows[e.RowIndex].FindControl("lbl_DegreeType") as Label; Label DegreeName = GridView1.Rows[e.RowIndex].FindControl("lbl_DegreeName") as Label; Label University = GridView1.Rows[e.RowIndex].FindControl("lbl_University") as Label; DropDownList Year = GridView1.Rows[e.RowIndex].FindControl("txt_Year") as DropDownList; TextBox Division = GridView1.Rows[e.RowIndex].FindControl("txt_Division") as TextBox; TextBox Percentage = GridView1.Rows[e.RowIndex].FindControl("txt_Percentage") as TextBox; TextBox Subjects = GridView1.Rows[e.RowIndex].FindControl("txt_Subjects") as TextBox; con = new MySqlConnection(cs); con.Open(); //updating the record MySqlCommand cmd = con.CreateCommand(); cmd.CommandText = "Update edu_core set Year= @Year, Division= @Division, Percentage= @Percentage, Subjects= @Subjects where User_ID=@user_id and DegreeType= @DegreeType and DegreeName=@DegreeName and University= @University"; cmd.Parameters.AddWithValue("@DegreeType", DegreeType.Text); cmd.Parameters.AddWithValue("@DegreeName", DegreeName.Text); cmd.Parameters.AddWithValue("@University", University.Text); cmd.Parameters.AddWithValue("@Year", int.Parse(Year.Text)); cmd.Parameters.AddWithValue("@Division", Division.Text); cmd.Parameters.AddWithValue("@Percentage", float.Parse(Percentage.Text)); cmd.Parameters.AddWithValue("@Subjects", Subjects.Text); cmd.Parameters.AddWithValue("@user_id", user_id); cmd.ExecuteNonQuery(); con.Close(); //Setting the EditIndex property to -1 to cancel the Edit mode in Gridview GridView1.EditIndex = -1; //Call ShowData_1 method for displaying updated data ShowData_1(); }
protected void gvSysConfig_RowUpdating(object sender, GridViewUpdateEventArgs e) { var tbConfigValue = gvSysConfig.Rows[gvSysConfig.EditIndex].Cells[1].Controls[0] as TextBox; if (tbConfigValue != null) { try { var c = new Config(); c.ConfigSystem = ConfigSystem.AcnClub; c.ConfigKey = gvSysConfig.DataKeys[gvSysConfig.EditIndex].Value.ToString(); c.ConfigValue = tbConfigValue.Text.Trim(); c.Update(); Config.Cache.RefreshCache(); } catch (Exception ex) { ClientScript.RegisterClientScriptBlock(typeof (string), "failed", $"alert('{ex.Message}');", true); } } gvSysConfig.EditIndex = -1; BindData(); }
protected void GridView1_RowUpdating(object sender, System.Web.UI.WebControls.GridViewUpdateEventArgs e) { con.Open(); //Finding the controls from Gridview for the row which is going to update idd = GridView1.Rows[e.RowIndex].FindControl("idd") as Label; // developer = GridView1.Rows[e.RowIndex].FindControl("d_name") as Label; Label Name = GridView1.Rows[e.RowIndex].FindControl("Name") as Label; Label Uname = GridView1.Rows[e.RowIndex].FindControl("Uname") as Label; Label pwd = GridView1.Rows[e.RowIndex].FindControl("pwd") as Label; TextBox e_name = GridView1.Rows[e.RowIndex].FindControl("e_Name") as TextBox; TextBox e_uname = GridView1.Rows[e.RowIndex].FindControl("e_Uname") as TextBox; TextBox e_pwd = GridView1.Rows[e.RowIndex].FindControl("e_pwd") as TextBox; //updating the records SqlCommand cmd = new SqlCommand(@"Update auth1 set Name='" + e_name.Text + "', username='******', password = '******' where id = '" + Convert.ToInt32(idd.Text) + "'", con); cmd.ExecuteNonQuery(); con.Close(); //Setting the EditIndex property to -1 to cancel the Edit mode in Gridview GridView1.EditIndex = -1; //Call ShowData method for displaying updated data ShowData(); }
protected void gvTeacherGroup_RowUpdating(object sender, GridViewUpdateEventArgs e) { String id = gvTeacherGroup.DataKeys[e.RowIndex].Value.ToString(); String strName = ((TextBox)gvTeacherGroup.Rows[e.RowIndex].Cells[2].FindControl("tbTeacherGroupName")).Text.ToString().Trim(); String managerName = ((TextBox)gvTeacherGroup.Rows[e.RowIndex].Cells[3].FindControl("tbLeaderName")).Text.ToString().Trim(); int managerId = -1; try { Users user = BLL.admin.user.UserManagement.getUserByName(managerName); if (user != null) managerId = user.Key; } catch (Exception ex) { }; t_Teacher_Group tg = new t_Teacher_Group(); tg.Id = Convert.ToInt32(id); tg.Name = strName; tg.LeaderId = managerId; BLL.admin.TeacherGroup.TeacherGroupManagement.updateTeacherGroup(tg); gvTeacherGroup.EditIndex = -1; //将GridView控件恢复为编辑前的状态。即更新完了就得回到非编辑状态 databind(); //更新完了之后,就得重新绑定,即重新从数据库中读取刚才更新的数据。 }
protected void ClienteGridView_RowUpdating(object sender, System.Web.UI.WebControls.GridViewUpdateEventArgs e) { //Obtem cada valor único do DataKeyNames int id = Convert.ToInt32(ClienteGridView.DataKeys[e.RowIndex].Value.ToString()); //Obtem o valor do TextBox no EditItemTemplet da linha clicada string nome = ((TextBox)ClienteGridView.Rows[e.RowIndex].FindControl("txtnome")).Text; string telefone = ((TextBox)ClienteGridView.Rows[e.RowIndex].FindControl("txttelefone")).Text; string cidade = ((TextBox)ClienteGridView.Rows[e.RowIndex].FindControl("txtcidade")).Text; string endereco = ((TextBox)ClienteGridView.Rows[e.RowIndex].FindControl("txtendereco")).Text; int cpf = Convert.ToInt32(((TextBox)ClienteGridView.Rows[e.RowIndex].FindControl("txtcpf")).Text); //ListaClientes.Find(x => x.Id == id).SetNome(nome).SetTelefone(telefone).SetCidade(cidade).SetEndereco(endereco).SetCpf(cpf); var item = ListaClientes.Find(x => x.Id == id); item.Nome = nome; item.Telefone = telefone; item.Cidade = cidade; item.Endereco = endereco; item.Cpf = cpf; //nenhuma linha no modo de edição ClienteGridView.EditIndex = -1; //preenche o grid nomvanete preencherGrid(); }
//INSTANT C# WARNING: Strict 'Handles' conversion only applies to 'WithEvents' fields declared in the same class - the event will be wired in 'SubscribeToEvents': //ORIGINAL LINE: Protected Sub GridView1_RowUpdating(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewUpdateEventArgs) Handles GridView1.RowUpdating protected void GridView1_RowUpdating(object sender, System.Web.UI.WebControls.GridViewUpdateEventArgs e) { if (b.DemoMode == false) { string Email = ((TextBox)(GridView1.Rows[e.RowIndex].Cells[2].Controls[0])).Text.Trim(); string FullName = ((TextBox)(GridView1.Rows[e.RowIndex].Cells[3].Controls[0])).Text.Trim(); DataLayer.SQLDataProvider data = new DataLayer.SQLDataProvider(); data.UpdataUserInformation(Email, FullName, GridView1.DataKeys[e.RowIndex].Values[0].ToString()); if (data.SQLError == null) { GridView1.EditIndex = -1; LoadData(); } else { DisplayError(data.SQLError.Message); } } else { Alert("You are not allowed to make changes in demo mode."); } }
protected void UpdateEdit(object sender, System.Web.UI.WebControls.GridViewUpdateEventArgs e) { GridViewRow row = grid.Rows[e.RowIndex]; System.Diagnostics.Debug.WriteLine(dt1.Rows[row.DataItemIndex]["OrderID"].ToString()); dt1.Rows[row.DataItemIndex]["OrderTrackingNumber"] = ((TextBox)(row.Cells[0].Controls[0])).Text; dt1.Rows[row.DataItemIndex]["OrderDate"] = ((TextBox)(row.Cells[1].Controls[0])).Text; dt1.Rows[row.DataItemIndex]["OrderCustomerNumber"] = ((TextBox)(row.Cells[2].Controls[0])).Text; dt1.Rows[row.DataItemIndex]["CustName"] = ((TextBox)(row.Cells[3].Controls[0])).Text; dt1.Rows[row.DataItemIndex]["CustOfficeAddress1"] = ((TextBox)(row.Cells[4].Controls[0])).Text; dt1.Rows[row.DataItemIndex]["OrderRouteNumber"] = ((TextBox)(row.Cells[5].Controls[0])).Text; grid.EditIndex = -1; BLL.UpdateOrder( ((TextBox)(row.Cells[0].Controls[0])).Text, ((TextBox)(row.Cells[1].Controls[0])).Text, ((TextBox)(row.Cells[2].Controls[0])).Text, ((TextBox)(row.Cells[3].Controls[0])).Text, ((TextBox)(row.Cells[4].Controls[0])).Text, ((TextBox)(row.Cells[5].Controls[0])).Text, dt1.Rows[row.DataItemIndex]["OrderID"].ToString() ); grid.DataSource = dt1; grid.DataBind(); }
protected void gridTrees_RowUpdating(object sender, GridViewUpdateEventArgs e) { DropDownList ddlTreeType = gridTrees.Rows[e.RowIndex].FindControl("ddlTreeTypes") as DropDownList; if (ddlTreeType == null) return; int treeType; if (!int.TryParse(ddlTreeType.SelectedValue, out treeType)) return; string idStr = gridTrees.Rows[e.RowIndex].Cells[1].Text; int id; if (!int.TryParse(idStr, out id)) return; TextBox txtDescription = gridTrees.Rows[e.RowIndex].FindControl("txtDescription") as TextBox; if (txtDescription == null) return; string description = txtDescription.Text; Tree tree = new Tree() { ID = id, TreeType = treeType, Description = description, }; bl.UpdateTree("School101", "School101", tree); gridTrees.EditIndex = -1; ReloadTreesGrid(); }
protected void GridView1_RowUpdating(object sender, System.Web.UI.WebControls.GridViewUpdateEventArgs e) { con.Open(); //Finding the controls from Gridview for the row which is going to update idd = GridView1.Rows[e.RowIndex].FindControl("idd") as Label; developer = GridView1.Rows[e.RowIndex].FindControl("d_name") as Label; Label sprintt = GridView1.Rows[e.RowIndex].FindControl("sprint") as Label; Label feature = GridView1.Rows[e.RowIndex].FindControl("feat") as Label; Label deadline = GridView1.Rows[e.RowIndex].FindControl("dline") as Label; Label creation = GridView1.Rows[e.RowIndex].FindControl("cd") as Label; DropDownList priority = GridView1.Rows[e.RowIndex].FindControl("e_pr") as DropDownList; TextBox status = GridView1.Rows[e.RowIndex].FindControl("status") as TextBox; TextBox remarks = GridView1.Rows[e.RowIndex].FindControl("remarks") as TextBox; Label header = GridView1.Rows[e.RowIndex].FindControl("tHeader") as Label; //updating the records SqlCommand cmd = new SqlCommand(@"Update Sprint_backlog set [sprint number]='" + sprintt.Text + "', Developer='" + developer.Text + "',feature = '" + feature.Text + "' ,[start date]='" + creation.Text + "' ,deadline='" + deadline.Text + "', priority='" + priority.SelectedItem.ToString() + "', remarks ='" + remarks.Text + "' , status = '" + status.Text + "' , [task Header] = '" + header.Text + "' where ID=" + Convert.ToInt32(idd.Text), con); cmd.ExecuteNonQuery(); con.Close(); //Setting the EditIndex property to -1 to cancel the Edit mode in Gridview GridView1.EditIndex = -1; //Call ShowData method for displaying updated data ShowData(); }
protected void gvProveedores_RowUpdating(object sender, GridViewUpdateEventArgs e) { var i = e.RowIndex; var cod = this.gvProveedores.Rows[i].Cells[0].Text; var raz = ( (TextBox)(this.gvProveedores.Rows[i].Cells[1].Controls[0])).Text; var dir = ( (TextBox)(this.gvProveedores.Rows[i].Cells[2].Controls[0])).Text; var tel = ( (TextBox)(this.gvProveedores.Rows[i].Cells[3].Controls[0])).Text; var dis = ( (TextBox)(this.gvProveedores.Rows[i].Cells[4].Controls[0])).Text; var rep = ( (TextBox)(this.gvProveedores.Rows[i].Cells[5].Controls[0])).Text; objProBE .Codigo = cod; objProBE .Razon = raz; objProBE .Direccion = dir; objProBE .Telefono = tel; objProBE .Distrito = dis; objProBE .Representante = rep; Response.Write(objProBL.ActualizarProveedor(objProBE)); gvProveedores.EditIndex = -1; gvProveedores .DataSource = objProBL.getProveedores(); gvProveedores.DataBind(); }
protected void gvUserSettings_RowUpdating(object sender, GridViewUpdateEventArgs e) { var value = gvUserSettings.Rows[e.RowIndex].Cells[3].Controls[0] as TextBox; if (value == null) { throw new InvalidOperationException( "Could not find the textbox with this value. This should not happen. Ever!"); } if (gvUserSettings.DataKeys[e.RowIndex] == null) { throw new InvalidOperationException("Could not find DataKey for this row"); } var rep = RepositoryFactory.GetRepository<ISettingRepository>(); var settingId = (int) gvUserSettings.DataKeys[e.RowIndex].Value; var setting = rep[settingId]; if (setting != null) { setting.Value = value.Text; } rep.Commit(setting); gvUserSettings.EditIndex = -1; PopulateUserSettings(); }
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e) { int gvr = e.RowIndex; string name = ((TextBox)GridView1.Rows[gvr].FindControl("txtName")).Text; GridViewRow row = (GridViewRow)GridView1.Rows[e.RowIndex]; HiddenField lblid = (HiddenField)row.FindControl("lblId"); int id = Convert.ToInt32(lblid.Value); District fd = new District(); fd.Id = id; fd.DistrictName = name; try { dMethods.Update(fd); GridView1.EditIndex = -1; BindGrid(); js.ShowAlert(this, "Record updated succesfully!"); } catch (Exception ex) { if (ex.InnerException.InnerException.Message.Contains("UNIQUE")) { js.ShowAlert(this, "District already exists! Please try another name."); } else { js.ShowAlert(this, ex.Message); } } }
protected void GridView2_RowUpdating(object sender, System.Web.UI.WebControls.GridViewUpdateEventArgs e) { if (coursename == null) { coursename = ddlCourseType.SelectedValue.Replace(" ", "_"); } //Finding the controls from Gridview for the row which is going to update Label id = GridView3.Rows[e.RowIndex].FindControl("lbl_ID") as Label; TextBox name = GridView3.Rows[e.RowIndex].FindControl("txt_Name") as TextBox; //TextBox marks = GridView3.Rows[e.RowIndex].FindControl("txt_City") as TextBox; TextBox Theory = GridView3.Rows[e.RowIndex].FindControl("txt_Theory") as TextBox; TextBox IA = GridView3.Rows[e.RowIndex].FindControl("txt_IA") as TextBox; TextBox Practical = GridView3.Rows[e.RowIndex].FindControl("txt_Pra") as TextBox; con.Open(); //updating the record table_name = coursename.Replace(" ", "_") + "_" + lbEntryType.SelectedItem.Text.Replace(" ", "_") + "_SUBJECTS"; SqlCommand cmd = new SqlCommand("Update " + table_name + " set SUBJECT_NAME ='" + name.Text + "', Theory = '" + Theory.Text + "', IA = '" + IA.Text + "', Practical = '" + Practical.Text + "' where ID=" + Convert.ToInt32(id.Text), con); cmd.ExecuteNonQuery(); cmd = new SqlCommand("Update " + table_name + " set Max_Marks = Theory + IA + Practical", con); cmd.ExecuteNonQuery(); con.Close(); //Setting the EditIndex property to -1 to cancel the Edit mode in Gridview GridView3.EditIndex = -1; //Call ShowData method for displaying updated data ShowData(); }
protected void GV_RowUpdating(object sender, GridViewUpdateEventArgs e) { using (OracleConnection conn = new OracleConnection(DBHelper.ConnectionString)) { string reason_id = GV.DataKeys[e.RowIndex].Values[0].ToString(); string reason_desc = ((TextBox)GV.Rows[e.RowIndex].FindControl("TxtDesc")).Text; string active = ((CheckBox)(GV.Rows[e.RowIndex].FindControl("ChkActive"))).Checked == true ? "1" : "0"; string sqlupdate = "update jp_lack_reason set reason_desc = '" + reason_desc + "',is_valid='" + active + "' where reason_id = '" + reason_id + "' "; OracleCommand updatecomm = new OracleCommand(sqlupdate, conn); try { conn.Open(); updatecomm.ExecuteNonQuery(); GV.EditIndex = -1; GVDataBind(); } catch (Exception ex) { conn.Close(); Response.Write("<script language=javascript>alert('" + ex.Message + "')</script>"); } finally { updatecomm.Dispose(); conn.Dispose(); conn.Close(); } } }
protected void UpdateAccountGrid_RowUpdating(object sender, System.Web.UI.WebControls.GridViewUpdateEventArgs e) { //Finding the controls from Gridview for the row which is going to update Label acc = UpdateAccountGrid.Rows[e.RowIndex].FindControl("lbl_acc") as Label; Label uname = UpdateAccountGrid.Rows[e.RowIndex].FindControl("txt_Name") as Label; TextBox fname = UpdateAccountGrid.Rows[e.RowIndex].FindControl("txt_Fname") as TextBox; TextBox lname = UpdateAccountGrid.Rows[e.RowIndex].FindControl("txt_Lname") as TextBox; TextBox dob = UpdateAccountGrid.Rows[e.RowIndex].FindControl("txt_dob") as TextBox; TextBox ph = UpdateAccountGrid.Rows[e.RowIndex].FindControl("txt_ph") as TextBox; TextBox email = UpdateAccountGrid.Rows[e.RowIndex].FindControl("txt_email") as TextBox; TextBox aadhar = UpdateAccountGrid.Rows[e.RowIndex].FindControl("txt_aadhar") as TextBox; TextBox accType = UpdateAccountGrid.Rows[e.RowIndex].FindControl("txt_accType") as TextBox; TextBox bal = UpdateAccountGrid.Rows[e.RowIndex].FindControl("txt_bal") as TextBox; TextBox address = UpdateAccountGrid.Rows[e.RowIndex].FindControl("txt_address") as TextBox; SqlConnection con = new SqlConnection(); con.ConnectionString = ConfigurationManager.ConnectionStrings["BankManagmentConn"].ConnectionString; con.Open(); //updating the record SqlCommand cmd = new SqlCommand("update Customer set firstname='" + fname.Text + "',lastname='" + lname.Text + "',dob='" + DateTime.ParseExact(dob.Text, "dd/MM/yyyy", null) + "',phoneno='" + ph.Text + "',email='" + email.Text + "',aadhar_no='" + aadhar.Text + "',account_type='" + accType.Text + "',balance='" + bal.Text + "',address='" + address.Text + "' where accountno=" + Convert.ToInt64(acc.Text), con); cmd.ExecuteNonQuery(); con.Close(); //Setting the EditIndex property to -1 to cancel the Edit mode in Gridview UpdateAccountGrid.EditIndex = -1; //Call ShowData method for displaying updated data ShowData(); }
protected void GridViewempEdit_RowUpdating(object sender, GridViewUpdateEventArgs e) { SqlConnection con = new SqlConnection(connectionstring); con.Open(); GridViewRow row = (GridViewRow)GridViewempEdit.Rows[e.RowIndex]; Label l1 = (Label)row.FindControl("lbleno"); int eno = Convert.ToInt32(l1.Text); TextBox txt4 = (TextBox)row.FindControl("txtsal"); int sal =Convert.ToInt32(txt4.Text); GridViewempEdit.EditIndex = -1; SqlCommand cmd = new SqlCommand("update Employee set salary=@sal where eno=@eno", con); cmd.Parameters.AddWithValue("@sal", sal); cmd.Parameters.AddWithValue("@eno", eno); cmd.ExecuteNonQuery(); con.Close(); bind(); lblmsg.Text = "Employe details updated"; }
protected void PrideRunorderGV_RowUpdating(object sender, GridViewUpdateEventArgs e) { //String orderId = ((TextBox)PrideRunOrderGV.Rows[e.RowIndex].Cells[1].Controls[0]).Text; //order_id //String status = ((DropDownList)PrideRunOrderGV.Rows[e.RowIndex].Cells[2].Controls[1]).SelectedItem.Value; // order_status //String paymentDate = ((TextBox)PrideRunOrderGV.Rows[e.RowIndex].Cells[3].Controls[0]).Text; //payment_date //String paymentType = ((TextBox)PrideRunOrderGV.Rows[e.RowIndex].Cells[4].Controls[0]).Text; //payment type String orderId = ((TextBox)PrideRunOrderGV.Rows[e.RowIndex].Cells[1].Controls[0]).Text; //order_id String status = ((DropDownList)PrideRunOrderGV.Rows[e.RowIndex].Cells[2].Controls[1]).SelectedItem.Value; // order_status String paymentDate = ((TextBox)PrideRunOrderGV.Rows[e.RowIndex].Cells[3].Controls[0]).Text; //payment_date String paymentType = ((TextBox)PrideRunOrderGV.Rows[e.RowIndex].Cells[4].Controls[0]).Text; //payment type //this line above does not work....i can't get hte value //String temp = PrideRunOrderGV.Rows[e.RowIndex].Cells[2].FindControl("statusListJovino").ToString(); //Session["statusSelected"] = (((DropDownList)sender).SelectedValue); //status = (String)Session["statusSelected"]; //controller.updateOrderStatus(Int16.Parse(orderId), status); controller.updateOrder(Int16.Parse(orderId), status, paymentDate, paymentType); PrideRunOrderGV.EditIndex = -1; this.rebind(); }
protected void gvReview_RowUpdating(Object sender, System.Web.UI.WebControls.GridViewUpdateEventArgs e) { int rowIndex = e.RowIndex; int id = int.Parse(gvReview.Rows[rowIndex].Cells[0].Text); TextBox TBox; TBox = (TextBox)gvReview.Rows[rowIndex].Cells[2].Controls[0]; String comment = TBox.Text; TBox = (TextBox)gvReview.Rows[rowIndex].Cells[3].Controls[0]; int quality = int.Parse(TBox.Text); TBox = (TextBox)gvReview.Rows[rowIndex].Cells[4].Controls[0]; int service = int.Parse(TBox.Text); TBox = (TextBox)gvReview.Rows[rowIndex].Cells[5].Controls[0]; int atmosphere = int.Parse(TBox.Text); TBox = (TextBox)gvReview.Rows[rowIndex].Cells[6].Controls[0]; int price = int.Parse(TBox.Text); objCommand.CommandType = CommandType.StoredProcedure; objCommand.CommandText = "UpdateReview"; objCommand.Parameters.AddWithValue("@theComment", comment); objCommand.Parameters.AddWithValue("@theQuality", quality); objCommand.Parameters.AddWithValue("@theService", service); objCommand.Parameters.AddWithValue("@theAtmosphere", atmosphere); objCommand.Parameters.AddWithValue("@thePrice", price); objCommand.Parameters.AddWithValue("@theID", id); objDB.DoUpdateUsingCmdObj(objCommand); gvReview.EditIndex = -1; ShowReview(); }
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e) { string s = GridView1.DataKeys[e.RowIndex].Value.ToString(); TextBox name = (TextBox)GridView1.Rows[e.RowIndex].FindControl("txtName"); TextBox year = (TextBox)GridView1.Rows[e.RowIndex].FindControl("txtLaunchYear"); if (name.Text.Trim() == "" || year.Text.Trim() == "") { Label16.Text = "Insert data on the textbox."; Label16.Visible = true; } else { Label16.Visible = false; int q = Active_Record.Music.UpdateMusicInfo(Convert.ToInt32(s), name.Text, year.Text); if (q == -1) { Label6.Text = "Error while updating music information. Try again later."; Label6.Visible = true; } else if (q == -99) { Label15.Text = "An error occurred while loading the page. Try again later."; Label15.Visible = true; } else { GridView1.EditIndex = -1; BindGridData(); } } }
protected void gvDisplay_RowUpdating(object sender, GridViewUpdateEventArgs e) { GridViewRow r = gvDisplay.Rows[e.RowIndex]; Label id = (r.FindControl("lblId") as Label); TextBox titre = (r.FindControl("txtTitre") as TextBox); TextBox prix = (r.FindControl("txtPrix") as TextBox); TextBox montantCharges = (r.FindControl("txtMontantCharges") as TextBox); //CRUD using (ServiceAgence.AgenceClient client = new ServiceAgence.AgenceClient()) { client.Open(); ServiceAgence.BienImmobilier bien = client.LireDetailsBienImmobilier(id.Text).Bien; bien.Titre = titre.Text; bien.Prix = Convert.ToDouble(prix.Text); bien.MontantCharges = Convert.ToDouble(montantCharges.Text); client.ModifierBienImmobilier(bien); client.Close(); } gvDisplay.EditIndex = -1; BindData(); }
protected void complainGridView_RowUpdating(object sender, GridViewUpdateEventArgs e) { int r = e.RowIndex; Label t1 = (Label)complainGridView.Rows[r].FindControl("Label1"); TextBox t2 = (TextBox)complainGridView.Rows[r].FindControl("pNameTextBox"); TextBox t3 = (TextBox)complainGridView.Rows[r].FindControl("hostelTextBox"); TextBox t4 = (TextBox)complainGridView.Rows[r].FindControl("roomTextBox"); TextBox t5 = (TextBox)complainGridView.Rows[r].FindControl("categoryTextBox"); TextBox t6 = (TextBox)complainGridView.Rows[r].FindControl("summaryTextBox"); TextBox t7 = (TextBox)complainGridView.Rows[r].FindControl("priorityTextBox"); TextBox t8 = (TextBox)complainGridView.Rows[r].FindControl("contactTextBox"); bool flag = aManager.Update(t1.Text, t2.Text, int.Parse(t3.Text), int.Parse(t4.Text), t5.Text, t6.Text, t7.Text, t8.Text); if (flag == true) { msgLabel.Text = "Update Successfully"; complainGridView.DataSource = aManager.ShowAllComplain(); complainGridView.EditIndex = -1; complainGridView.DataBind(); } else { msgLabel.Text = "Not Updated, Sorry!!!!!"; } }
protected void gvSample_RowUpdating(object sender, System.Web.UI.WebControls.GridViewUpdateEventArgs e) { this.CONTRACT_PKID = int.Parse(gvSample.DataKeys[e.RowIndex].Values[0].ToString()); TextBox _txtName = (TextBox)gvSample.Rows[e.RowIndex].FindControl("txtName"); TextBox _txtPhone = (TextBox)gvSample.Rows[e.RowIndex].FindControl("txtPhone_number"); TextBox _txtEmail = (TextBox)gvSample.Rows[e.RowIndex].FindControl("txtEmail"); TextBox _txtDepartment = (TextBox)gvSample.Rows[e.RowIndex].FindControl("txtDepartment"); m_customer_contract_person contract = List.Find(x => x.ID == this.CONTRACT_PKID); if (contract != null) { contract.company_id = objCustomer.ID; contract.name = _txtName.Text; contract.phone_number = _txtPhone.Text; contract.email = _txtEmail.Text; contract.department = _txtDepartment.Text; } gvSample.EditIndex = -1; gvSample.DataSource = ListShow; gvSample.DataBind(); btnAdd.Enabled = true; }
protected void GridView1_RowUpdating(object sender, System.Web.UI.WebControls.GridViewUpdateEventArgs e) { //Finding the controls from Gridview for the row which is going to update Label id = GridView1.Rows[e.RowIndex].FindControl("lbl_ID") as Label; TextBox name = GridView1.Rows[e.RowIndex].FindControl("txt_Name") as TextBox; TextBox Address = GridView1.Rows[e.RowIndex].FindControl("txt_Address") as TextBox; DropDownList Brick = GridView1.Rows[e.RowIndex].FindControl("ddlBrick") as DropDownList; //string Brick = (GridView1.Rows[e.RowIndex].FindControl("ddlBrick") as DropDownList).SelectedItem.Value; DropDownList NoOfPatients = GridView1.Rows[e.RowIndex].FindControl("ddlNoOfPatients") as DropDownList; DropDownList PHabit = GridView1.Rows[e.RowIndex].FindControl("ddlPHabit") as DropDownList; myConn = new SqlConnection(ConfigurationManager.ConnectionStrings["AmounCrmConnectionString"].ConnectionString); myConn.Open(); //updating the record SqlCommand cmd = new SqlCommand("Update DoctorsUpdate set Name=N'" + name.Text + "',EntityAddress=N'" + Address.Text + "',Ubrick=" + Brick.SelectedItem.Value + " ,UNoOfPatients=" + NoOfPatients.SelectedValue + " ,UPHabit=" + PHabit.SelectedValue + " ,txtbrick='" + Brick.SelectedItem + "' ,txtNoOfPatients='" + NoOfPatients.SelectedItem + "' ,txtPHabit='" + PHabit.SelectedItem + "' where ID=" + Convert.ToInt32(id.Text), myConn); //SqlCommand cmd = new SqlCommand("Update DoctorsUpdate set Name=N'" + name.Text + "' where ID=" + Convert.ToInt32(id.Text), myConn); cmd.ExecuteNonQuery(); myConn.Close(); //Setting the EditIndex property to -1 to cancel the Edit mode in Gridview GridView1.EditIndex = -1; //Call ShowData method for displaying updated data ShowEmpDetails(); }
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e) { ControladorTecnico control = new ControladorTecnico(); GridViewRow fila = GridView1.Rows[e.RowIndex]; int id_orden = Convert.ToInt32(GridView1.DataKeys[e.RowIndex].Values[0]); string RutTec = (fila.FindControl("Label2") as Label).Text; int ID_recep = Convert.ToInt32((fila.FindControl("Label3") as Label).Text); string estado = (fila.FindControl("txtEstado") as TextBox).Text; string observa = (fila.FindControl("txtObservacion") as TextBox).Text; int precio = Convert.ToInt32((fila.FindControl("txtPrecio") as TextBox).Text); string estadopago = (fila.FindControl("txtEstadoPago") as TextBox).Text; int tipo = Convert.ToInt32((fila.FindControl("Label4") as Label).Text); Orden_Trabajo orden = new Orden_Trabajo { ID_Orden = id_orden, RUT_Usuario = RutTec, ID_Recepcion = ID_recep, Estado= estado, Observacion=observa, Precio=precio, Estado_pago=estadopago, ID_TipoPago = tipo }; control.EditarOrden(orden); GridView1.EditIndex = -1; cargarBOX(); }
protected void gridProduto_RowUpdating(object sender, GridViewUpdateEventArgs e) { try { int index = gridProduto.EditIndex; GridViewRow row = gridProduto.Rows[index]; Produto p = new Produto(); p.IdProduto = Convert.ToInt32(gridProduto.DataKeys[e.RowIndex].Value.ToString()); p.Nome = Convert.ToString(((TextBox)(row.Cells[2].Controls[0])).Text); p.Preco = Convert.ToDecimal(((TextBox)(row.Cells[3].Controls[0])).Text); p.Quantidade = Convert.ToInt32(((TextBox)(row.Cells[4].Controls[0])).Text); p.Descricao = Convert.ToString(((TextBox)(row.Cells[5].Controls[0])).Text); ProdutoDal d = new ProdutoDal(); d.Update(p); lblMensagem.Text = "Produto Atualizado."; gridProduto.EditIndex = -1; gridBind(); } catch (Exception ex) { lblMensagem.Text = "Erro ao atualizar Produto" + ex.Message; } }
protected void GridView1_RowUpdating(object sender, System.Web.UI.WebControls.GridViewUpdateEventArgs e) { //Finding the controls from Gridview for the row which is going to update Label id = GridView1.Rows[e.RowIndex].FindControl("lbl_bookIsbn") as Label; TextBox Bname = GridView1.Rows[e.RowIndex].FindControl("txt_bookName") as TextBox; TextBox Bcategory = GridView1.Rows[e.RowIndex].FindControl("txt_bookCategory") as TextBox; TextBox Bauthor = GridView1.Rows[e.RowIndex].FindControl("txt_bookAuthor") as TextBox; TextBox BrelYear = GridView1.Rows[e.RowIndex].FindControl("txt_bookRelYear") as TextBox; TextBox BpageNum = GridView1.Rows[e.RowIndex].FindControl("txt_bookPageNum") as TextBox; TextBox Bkeys = GridView1.Rows[e.RowIndex].FindControl("txt_bookKeys") as TextBox; con = new SqlConnection(WebConfigurationManager.ConnectionStrings["AkinSoftConnect"].ConnectionString); con.Open(); //updating the record SqlCommand cmd = new SqlCommand("Update Book set BookName='" + Bname.Text + "',BookCategory='" + Bcategory.Text + "',BookAuthor='" + Bauthor.Text + "',BookRelYear='" + BrelYear.Text + "',BookPageNum='" + BpageNum.Text + "',BookKeys ='" + Bkeys.Text + "' where BookISBN= + '" + id.Text + "'", con); cmd.ExecuteNonQuery(); con.Close(); //Setting the EditIndex property to -1 to cancel the Edit mode in Gridview GridView1.EditIndex = -1; //Call ShowData method for displaying updated data ShowData(); }
protected void gvRmoaAlerts_RowUpdating(object sender, System.Web.UI.WebControls.GridViewUpdateEventArgs e) { //DailyAlertEntity alertToUpdate = gvRmoaAlerts.Rows[e.RowIndex].DataItem as DailyAlertEntity; DailyAlertEntity alertToUpdate = new DailyAlertEntity(); alertToUpdate.ID = int.Parse(txtID.Text); TextBox txtComments = (TextBox)gvRmoaAlerts.Rows[e.RowIndex].FindControl("txtRmoaComments"); alertToUpdate.Comment = txtComments.Text; DropDownList ddlStatus = (DropDownList)gvRmoaAlerts.Rows[e.RowIndex].FindControl("ddlRmoaStatus"); alertToUpdate.Status = ddlStatus.Text; alertToUpdate.Username = HttpContext.Current.User.Identity.Name; try { new DailyAlertBLL().UpdateForRmoa(alertToUpdate); Response.Redirect(Request.Url.AbsoluteUri); } catch (Exception ex) { errorMessages.CssClass = "error"; errorMessages.Text = ex.Message; currTabNo.Text = "0"; } }
protected void gvReviews_RowUpdating(Object sender, System.Web.UI.WebControls.GridViewUpdateEventArgs e) { // retrieve the row index for which the Update button was clicked // and retrieve the ReviewNumber from the first column (BoundField) in that row. int rowIndex = e.RowIndex; string reviewID = gvReviews.Rows[rowIndex].Cells[ID_COL].Text; string restaurantName = gvReviews.Rows[rowIndex].Cells[RESTAURANT_NAME_COL].Text; lblDisplay.Text = "review ID = " + reviewID; // Retrieve a reference to a TextBox created by the GridView when it's in edit-mode TextBox TBox = (TextBox)gvReviews.Rows[rowIndex].Cells[COMMENTS_COL].Controls[FIRST_CONTROL]; string reviewComments = TBox.Text; TBox = (TextBox)gvReviews.Rows[rowIndex].Cells[FOOD_COL].Controls[FIRST_CONTROL]; int foodRating = Int32.Parse(TBox.Text); TBox = (TextBox)gvReviews.Rows[rowIndex].Cells[SERVICE_COL].Controls[FIRST_CONTROL]; int serviceRating = Int32.Parse(TBox.Text); TBox = (TextBox)gvReviews.Rows[rowIndex].Cells[PRICE_COL].Controls[FIRST_CONTROL]; int priceRating = Int32.Parse(TBox.Text); // Update SqlCommand objCommand = new SqlCommand(); objCommand.CommandType = CommandType.StoredProcedure; objCommand.CommandText = "UpdateReview"; objCommand.Parameters.AddWithValue("@reviewID", Int32.Parse(reviewID)); objCommand.Parameters.AddWithValue("@reviewText", reviewComments); objCommand.Parameters.AddWithValue("@ratingFood", foodRating); objCommand.Parameters.AddWithValue("@ratingService", serviceRating); objCommand.Parameters.AddWithValue("@ratingPrice", priceRating); if (objDB.DoUpdateUsingCmdObj(objCommand) != -1) { lblDisplay.Text = "Review Updated Successfully."; } // Set the GridView back to the original state. // No rows currently being edited. gvReviews.EditIndex = -1; updateAverageRatings(restaurantName); populateReviews(); }
protected void gvData_RowUpdating(object sender, GridViewUpdateEventArgs e) { try { TextBox txtOldnoQty = (TextBox)gvData.Rows[e.RowIndex].FindControl("txtOldNoQty"); TextBox txtNewnoQty = (TextBox)gvData.Rows[e.RowIndex].FindControl("txtNewNoQty"); int rtn = 0; if (txtNewnoQty.Text != "" && txtOldnoQty.Text != "") { //int.Parse(Request["id"]) rtn = PH_RateCalc.PH_RateCaclAdj_TransportInsert(AppCode.strConnDB, gvData.DataKeys[e.RowIndex].Value.ToString(), int.Parse(Request["id"]), int.Parse(txtOldnoQty.Text)); if (rtn > 0) rtn = PH_RateCalc.PH_RateCaclAdj_TransportInsert(AppCode.strConnDB, gvData.DataKeys[e.RowIndex].Value.ToString(), int.Parse(Request["id"]), int.Parse(txtNewnoQty.Text)); } string message = rtn > 0 ? "Save Data Successfull" : "Save Data Not Successfull"; ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "alertmsg", "alert('" + message + "');", true); gvData.EditIndex = -1; DataBindTrans(true); } catch(Exception ex) { lblErr.Text = ex.Message; PH_ExceptionManager.WriteError(ex.Message); } }
protected void grDS_RowUpdating(object sender, GridViewUpdateEventArgs e) { GridViewRow row = grDS.Rows[e.RowIndex]; TextBox txtmahoa = row.Cells[1].Controls[0] as TextBox; TextBox txttendonvi = row.Cells[2].Controls[0] as TextBox; TextBox txtdiachi = row.Cells[3].Controls[0] as TextBox; TextBox txtmst = row.Cells[4].Controls[0] as TextBox; int id=Int32.Parse(grDS.DataKeys[e.RowIndex].Value.ToString()); DonViDTO dv = new DonViDTO(); dv.Id_DonVi = id; dv.TenDonVi = txttendonvi.Text; dv.DiaChi = txtdiachi.Text; dv.MaHoa = txtmahoa.Text; dv.MaSoThue = txtmst.Text; DonViBHDAO dvdao = new DonViBHDAO(); bool up=dvdao.DonViUpdate(dv); if (up == true) { e.Cancel = true; grDS.EditIndex = -1; int ma = int.Parse(drNBH.SelectedItem.Value.ToString()); loadDS(ma); } else Response.Write(""); }
protected void gvRestaurants_RowUpdating(Object sender, System.Web.UI.WebControls.GridViewUpdateEventArgs e) { // retrieve the row index for which the Update button was clicked // and retrieve the ReviewNumber from the first column (BoundField) in that row. int rowIndex = e.RowIndex; string restaurantID = gvRestaurants.Rows[rowIndex].Cells[ID_COL].Text; lblDisplay.Text = "ID = " + restaurantID; // Retrieve a reference to a TextBox created by the GridView when it's in edit-mode TextBox TBox = (TextBox)gvRestaurants.Rows[rowIndex].Cells[RESTAURANT_NAME_COL].Controls[FIRST_CONTROL]; string restaurantName = TBox.Text; TBox = (TextBox)gvRestaurants.Rows[rowIndex].Cells[CATEGORY_COL].Controls[FIRST_CONTROL]; string categoryName = TBox.Text; // Update SqlCommand objCommandName = new SqlCommand(); objCommandName.CommandType = CommandType.StoredProcedure; objCommandName.CommandText = "UpdateRestaurantName"; objCommandName.Parameters.AddWithValue("@restaurantID", Int32.Parse(restaurantID)); objCommandName.Parameters.AddWithValue("@restaurantname", restaurantName); SqlCommand objCommandCat = new SqlCommand(); objCommandCat.CommandType = CommandType.StoredProcedure; objCommandCat.CommandText = "UpdateCategoryname"; objCommandCat.Parameters.AddWithValue("@restaurantID", Int32.Parse(restaurantID)); objCommandCat.Parameters.AddWithValue("@categoryName", categoryName); if (objDB.DoUpdateUsingCmdObj(objCommandName) != -1 && objDB.DoUpdateUsingCmdObj(objCommandCat) != -1) { lblDisplay.Text = "Restaurant Updated Successfully."; } // Set the GridView back to the original state. // No rows currently being edited. gvRestaurants.EditIndex = -1; populateRestaurants(); }
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e) { TextBox tb_Name = (TextBox)GridView1.Rows[e.RowIndex].FindControl("tb_Name"); int id = Convert.ToInt32(GridView1.DataKeys[e.RowIndex].Values[0].ToString()); var updTest = from test in _eJDataContext.Tests.ToList() where test.Id == id select test; foreach (Tests updT in updTest) { updT.Name = tb_Name.Text; } try { _eJDataContext.SubmitChanges(); } catch { _eJDataContext.ChangeConflicts.ResolveAll(RefreshMode.KeepChanges); { try { _eJDataContext.SubmitChanges(); } catch (Exception exept) { Console.WriteLine("Error: " + exept); } } } GridView1.EditIndex = -1; FillCustomerInGrid(); }
protected void GridViewProsjektAnsvarligInsert_RowUpdating(object sender, GridViewUpdateEventArgs e) { GridViewRow row = GridViewProsjektAnsvarligInsert.Rows[e.RowIndex]; try { string surname = e.NewValues["surname"].ToString(); string firstname = e.NewValues["firstname"].ToString(); string username = e.NewValues["username"].ToString(); string password = e.NewValues["password"].ToString(); string phone = e.NewValues["phone"].ToString(); string mail = e.NewValues["mail"].ToString(); DropDownList team = (DropDownList)row.FindControl("dropDownTeam"); DropDownList userType = (DropDownList)row.FindControl("dropDownBruker"); int teamID = Convert.ToInt32(team.SelectedValue); int userTypeID = Convert.ToInt32(userType.SelectedValue); string query = String.Format("INSERT INTO User (surname, firstname, password, username, phone, mail, teamID, groupID, aktiv) VALUES('{0}', '{1}', '{2}', '{3}', '{4}', '{5}', '{6}', {7}, {8})", surname, firstname, password, username, phone, mail, teamID, userTypeID, "1"); db.InsertDeleteUpdate(query); GridViewProsjektAnsvarligInsert.EditIndex = -1; GridViewInsertEmpty(); beskjed.Text = "Ny brukeren er lagt til"; } catch (Exception exception) { string error = exception.Message; beskjed.Text = "Det oppsto en feil: " + error; } }
protected void GridView1_RowUpdating(object sender, System.Web.UI.WebControls.GridViewUpdateEventArgs e) { //Finding the controls from Gridview for the row which is going to update SqlCommand cmd; int id = Convert.ToInt32(GridViewManageEmployee.DataKeys[e.RowIndex].Values[0]); TextBox name = GridViewManageEmployee.Rows[e.RowIndex].FindControl("txt_ename") as TextBox; TextBox emailid = GridViewManageEmployee.Rows[e.RowIndex].FindControl("txt_email") as TextBox; TextBox mobile = GridViewManageEmployee.Rows[e.RowIndex].FindControl("txt_mobile") as TextBox; TextBox pincode = GridViewManageEmployee.Rows[e.RowIndex].FindControl("txt_pincode") as TextBox; TextBox address = GridViewManageEmployee.Rows[e.RowIndex].FindControl("txt_address") as TextBox; DropDownList isactive = GridViewManageEmployee.Rows[e.RowIndex].FindControl("ddlisactive") as DropDownList; con = new SqlConnection(connection); con.Open(); try { if (name.Text == "" || emailid.Text == "" || mobile.Text == "" || pincode.Text == "" || address.Text == "") { throw new Exception("Fields Can't be left empty"); } cmd = new SqlCommand("Update user_info set uname='" + name.Text + "',emailid='" + emailid.Text + "',mobile='" + mobile.Text + "',pincode='" + pincode.Text + "',address='" + address.Text + "',isActive='" + isactive.SelectedValue.ToString() + "' where id=" + Convert.ToInt32(id), con); cmd.ExecuteNonQuery(); con.Close(); GridViewManageEmployee.EditIndex = -1; ListEmployees(); } catch (Exception ex) { ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert(\"Error! " + ex.Message + " Please check the data\");", true); } }
protected void GridViewMessages_RowUpdating(object sender, GridViewUpdateEventArgs e) { using (var context = new ApplicationDbContext()) { string contents = (this.GridViewMessages.Rows[e.RowIndex].FindControl("TextBoxContents") as TextBox).Text; if (string.IsNullOrWhiteSpace(contents)) { LabelErrorMessage.Text = "Contents cannot be empty"; e.Cancel = true; return; } int messageId = Convert.ToInt32(this.GridViewMessages.DataKeys[e.RowIndex].Value); var message = context.Messages.FirstOrDefault(m => m.Id == messageId); if (message == null) { LabelErrorMessage.Text = "No message selected."; e.Cancel = true; return; } message.Contents = contents; context.Entry<Message>(message).State = EntityState.Modified; context.SaveChanges(); DataBind(); Response.Redirect(Request.RawUrl); e.Cancel = true; } }
protected void gvAvailableProducts_RowUpdating(object sender, GridViewUpdateEventArgs e) { FileUpload fileupload1 = (FileUpload)gvAvailableProducts.Rows[e.RowIndex].FindControl("FileUpload1"); int ProductID = Int32.Parse(((Label)gvAvailableProducts.Rows[e.RowIndex].FindControl("Label5")).Text); string Name = ((TextBox)gvAvailableProducts.Rows[e.RowIndex].FindControl("TextBox1")).Text; string Description= ((TextBox)gvAvailableProducts.Rows[e.RowIndex].FindControl("TextBox4")).Text; int CategoryID = Int32.Parse(((DropDownList)gvAvailableProducts.Rows[e.RowIndex].FindControl("DropDownList1")).SelectedValue.ToString()); int ProductPrice = Int32.Parse(((TextBox)gvAvailableProducts.Rows[e.RowIndex].FindControl("TextBox2")).Text); string ProductImage = ((TextBox)gvAvailableProducts.Rows[e.RowIndex].FindControl("txtImg")).Text; if (fileupload1.PostedFile != null && fileupload1.HasFile) { SaveProductPoto(fileupload1); ProductImage = "~/ProductImages/" + fileupload1.FileName; } ShoppingCart k = new ShoppingCart() { ProductID = ProductID, ProductName = Name, ProductPrice = ProductPrice, ProductImage = ProductImage, ProductDescription = Description, CategoryID = CategoryID }; k.UpdateProduct(); gvAvailableProducts.EditIndex = -1; GetProducts(0); }
protected void gvSchedule_RowUpdating(object sender, GridViewUpdateEventArgs e) { var tbScheduleType = gvSchedule.Rows[gvSchedule.EditIndex].Cells[1].Controls[0] as TextBox; var tbDailyTime = gvSchedule.Rows[gvSchedule.EditIndex].Cells[3].Controls[0] as TextBox; var tbMinutes = gvSchedule.Rows[gvSchedule.EditIndex].Cells[4].Controls[0] as TextBox; var tbIsSystem = gvSchedule.Rows[gvSchedule.EditIndex].Cells[6].Controls[0] as TextBox; var tbIsActive = gvSchedule.Rows[gvSchedule.EditIndex].Cells[7].Controls[0] as TextBox; if (tbScheduleType != null && tbDailyTime != null && tbMinutes != null && tbIsSystem != null && tbIsActive != null) { try { var s = Schedule.Single(gvSchedule.DataKeys[gvSchedule.EditIndex].Value.ToString()); s.ScheduleType = tbScheduleType.Text.Trim(); s.DailyTime = Convert.ToInt32(tbDailyTime.Text.Trim()); s.Minutes = Convert.ToInt32(tbMinutes.Text.Trim()); s.IsSystem = Convert.ToBoolean(tbIsSystem.Text.Trim()); s.IsActive = Convert.ToBoolean(tbIsActive.Text.Trim()); s.Update(); } catch (Exception ex) { ClientScript.RegisterClientScriptBlock(typeof (string), "failed", $"alert('{ex.Message}');", true); } } gvSchedule.EditIndex = -1; BindData(); }
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e) { try { int id = Convert.ToInt32(GridView1.DataKeys[e.RowIndex].Values[0].ToString()); string Title = ((TextBox)GridView1.Rows[e.RowIndex].FindControl("Title")).Text; string Describe = ((TextBox)GridView1.Rows[e.RowIndex].FindControl("Describe")).Text; AgreementModel mode = new AgreementModel(); mode.AgreementID = id; mode.Title = Title; mode.Describe = Describe; if (DbDataLoader.Update(mode)) { GridView1.EditIndex = -1; BindData(); } } catch (Exception erro) { Response.Write("错误信息:" + erro.Message); } }
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e) { GridViewRow row = (GridViewRow)GridView1.Rows[e.RowIndex]; Label lblID = (Label)row.FindControl("ID"); TextBox factObject = (TextBox)row.FindControl("FactObject"); TextBox worktype = (TextBox)row.FindControl("WorkType"); TextBox costname = (TextBox)row.FindControl("CostName"); TextBox unitname = (TextBox)row.FindControl("UnitName"); TextBox labor = (TextBox)row.FindControl("Labor"); TextBox materials = (TextBox)row.FindControl("Materials"); TextBox mechanisms = (TextBox)row.FindControl("Mechanisms"); int factId = int.Parse(lblID.Text); GridView1.EditIndex = -1; conn.Open(); SqlCommand cmd = new SqlCommand("update Fact set FactObject='" + factObject.Text + "', WorkType='" + worktype.Text + "', CostName='" + costname.Text + "', UnitName='" + unitname.Text + "', Labor='" + labor.Text + "', Materials='" + materials.Text + "', Mechanisms='" + mechanisms.Text + "', FactID=" + planID + ", Status=" + 1 + " where ID=" + factId, conn); cmd.ExecuteNonQuery(); conn.Close(); gvbind(); //GridView1.DataBind(); }
protected void OnRowUpdating(object sender, GridViewUpdateEventArgs e) { GridViewRow row = GV_Pilots.Rows[e.RowIndex]; int idPilot= Convert.ToInt32(GV_Pilots.DataKeys[e.RowIndex].Values[0]); string mail = (row.FindControl("txtEmail") as TextBox).Text; string name = (row.FindControl("txtFstName") as TextBox).Text; string lstName = (row.FindControl("txtLstName") as TextBox).Text; string cert = (row.FindControl("txtCert") as TextBox).Text; string flightTime = (row.FindControl("txtTVuelo") as TextBox).Text; string certDate = (row.FindControl("txtCertDate") as TextBox).Text; using (DroidikaContextDataContext ctx = new DroidikaContextDataContext()) { dPilot pil = (from p in ctx.dPilots where p.id == idPilot select p).FirstOrDefault(); pil.email = mail; pil.fstName = name; pil.lstName = lstName; pil.certificate = char.Parse(cert); pil.flightTime = Int32.Parse(flightTime); pil.certificateDate = DateTime.Parse(certDate); ctx.SubmitChanges(); } GV_Pilots.EditIndex = -1; this.BindGrid(); }
protected void RetrievalFormGridView_RowEditing_RowUpdating(object sender, GridViewUpdateEventArgs e) { GridViewRow row = RetrievalFormGridView.Rows[e.RowIndex]; string itemId = row.Cells[0].Text; string stock = ((TextBox)row.Cells[4].Controls[1]).Text; int num; if (!(int.TryParse(stock, out num))) { row.ForeColor = Color.Red; } else if (Convert.ToInt32(stock)<0) { row.ForeColor = Color.Red; } else { ClassLibrary.Entities.Item item = new ClassLibrary.Entities.Item(); item.ItemId = itemId; item.StockBalance = Convert.ToInt32(stock); generateStationaryRetrievalFormController.updateStock(item); RetrievalFormGridView.EditIndex = -1; dataBind(); row.ForeColor = Color.Black; } }
protected void _categoriesGV_RowUpdating(object sender, GridViewUpdateEventArgs e) { string newCategoryName, id; try { id = e.Keys[0].ToString(); newCategoryName = e.NewValues["categoryName"].ToString(); if (string.IsNullOrEmpty(newCategoryName) || string.IsNullOrEmpty(id)) throw new Exception("Invalid arguments!"); // check is new category name, already exists to another gorup if (Articles.ArticleCategoryExist(newCategoryName, id)) { e.Cancel = true; ScriptManager.RegisterStartupScript(Page, GetType(), "unknownError", "alert('" + Resources.Resources.CategoryNameExist + "!');", true); } } catch (Exception) { e.Cancel = true; ScriptManager.RegisterStartupScript(Page, GetType(), "unknownError", "alert('" + Resources.Resources.UnknownError + "!');", true); } }
protected void GridView1_RowUpdating(object sender, System.Web.UI.WebControls.GridViewUpdateEventArgs e) { if (coursename == null) { coursename = ddlCourseType.Items[0].Value.Replace(" ", "_"); } string pno = personal_no; //Finding the controls from Gridview for the row which is going to update Label id1 = GridView3.Rows[e.RowIndex].FindControl("lbl_ID") as Label; TextBox id = GridView3.Rows[e.RowIndex].FindControl("txt_No") as TextBox; TextBox name = GridView3.Rows[e.RowIndex].FindControl("txt_Name") as TextBox; TextBox marks = GridView3.Rows[e.RowIndex].FindControl("txt_Rank") as TextBox; con.Open(); //updating the record table_name = coursename.Replace(" ", "_") + "_" + ddlCourseNo.SelectedValue.Replace("-", string.Empty) + "_" + lbEntryType.SelectedItem.Text.Replace(" ", "_"); SqlCommand cmd = new SqlCommand("Update " + table_name + " set Personal_No ='" + id.Text + "', Name='" + name.Text + "', Rank ='" + marks.Text + "' where Personal_no = '" + id1.Text + "'", con); cmd.ExecuteNonQuery(); con.Close(); //Setting the EditIndex property to -1 to cancel the Edit mode in Gridview GridView3.EditIndex = -1; //Call ShowData method for displaying updated data ShowData(); }
protected void GridView1_OnRowUpdating(object sender, GridViewUpdateEventArgs e) { GridViewRow gr = this.GridView1.Rows[e.RowIndex] as GridViewRow; FileUpload MyFileUpload = gr.Cells[2].FindControl("FileUpload1") as FileUpload; TextBox MyTextBox1 = gr.Cells[1].FindControl("TextBox1") as TextBox; TextBox MyTextBox2 = gr.Cells[3].FindControl("TextBox2") as TextBox; if (MyFileUpload.HasFile) { MyFileUpload.SaveAs(HttpContext.Current.Server.MapPath("~/images/SFForms/" + MyFileUpload.FileName)); SqlDataSource1.UpdateParameters.Add("FormName", MyTextBox1.Text); SqlDataSource1.UpdateParameters.Add("FormPath", "~/images/SFForms/" + MyFileUpload.FileName); SqlDataSource1.UpdateParameters.Add("FormDescription", MyTextBox2.Text); SqlDataSource1.UpdateParameters.Add("ID", e.Keys[0].ToString()); SqlDataSource1.Update(); } else { SqlDataSource1.UpdateParameters.Add("FormName", MyTextBox1.Text); SqlDataSource1.UpdateParameters.Add("FormPath", Literal1.Text); SqlDataSource1.UpdateParameters.Add("FormDescription", MyTextBox2.Text); SqlDataSource1.UpdateParameters.Add("ID", e.Keys[0].ToString()); SqlDataSource1.Update(); } GridView1.EditIndex = -1; GridView1.DataBind(); }
protected void ClienteGridView_RowUpdating(object sender, System.Web.UI.WebControls.GridViewUpdateEventArgs e) { string strCon = " server=localhost;uid=root;pwd=12345;database=fg "; //Obtem cada valor único do DataKeyNames int idmateria = Convert.ToInt32(ClienteGridView.DataKeys[e.RowIndex].Value.ToString()); //Obtem o valor do TextBox no EditItemTemplet da linha clicada string nome = ((TextBox)ClienteGridView.Rows[e.RowIndex].FindControl("txtnome")).Text; string carga_horaria = ((TextBox)ClienteGridView.Rows[e.RowIndex].FindControl("txtendereco")).Text; string nome_prof = ((TextBox)ClienteGridView.Rows[e.RowIndex].FindControl("txtemail")).Text; //abre a conexão MySqlConnection con = new MySqlConnection(strCon); con.Open(); //Utiliza a stored procedure sproc_AtualizaCliente na conexão MySqlCommand cmd = new MySqlCommand("( @idmateria int, @nome varchar(45), @carga_horaria int(11), @nome_prof char(45)) AS update Cliente set nome=nome, carga_horaria=@carga_horaria, nome_prof=@nome_prof where idmateria=@idmateria", con); //define o tipo de comando cmd.CommandType = CommandType.StoredProcedure; //passa os parâmetros para a stored procedure cmd.Parameters.AddWithValue("@idmateria ", idmateria); cmd.Parameters.AddWithValue("@nome ", nome); cmd.Parameters.AddWithValue("@carga_horaria ", carga_horaria); cmd.Parameters.AddWithValue("@nome_prof ", nome_prof); //Método que retorna as linhas afetadas cmd.ExecuteNonQuery(); //nenhuma linha no modo de edição ClienteGridView.EditIndex = -1; //preenche o grid nomvanete preencheGrid(); }