protected void User_grd_RowUpdating(object sender, GridViewUpdateEventArgs e) { Id_hfd.Value = User_grd.DataKeys[User_grd.EditIndex].Value.ToString(); DropDownList Ddl = (DropDownList)User_grd.Rows[e.RowIndex].FindControl("Stategrd_ddl"); DropDownList Ddl1 = (DropDownList)User_grd.Rows[e.RowIndex].FindControl("Districtgrd_ddl"); DropDownList Ddl2 = (DropDownList)User_grd.Rows[e.RowIndex].FindControl("Party_ddl"); TextBox Txt1 = (TextBox)User_grd.Rows[e.RowIndex].FindControl("Name_txt"); string id = User_grd.DataKeyNames[e.RowIndex].ToString(); UpdateVoterTableAdapter Vt = new UpdateVoterTableAdapter(); object Chk = Vt.UpdateCandidateList(Id_hfd.Value, Txt1.Text, Ddl2.SelectedValue, Ddl1.SelectedValue); bool Check = Convert.ToBoolean(Chk); if (Check == true) { // ScriptManager.RegisterStartupScript(this, this.GetType(), "popup", "alert('Candidate Updated Successfully');window.location='EditRemoveCandidate.aspx';", true); StateSelect_pnl.Visible = false; StateDistrictGrid_pnl.Visible = true; User_grd.EditIndex = -1; GetUser(); User_grd.Visible = true; } else { Message_lbl.Text = "Cannot Update At this Time"; Message_lbl.ForeColor = System.Drawing.Color.Red; } }
protected void User_grd_RowDeleting(object sender, GridViewDeleteEventArgs e) { User_grd.EditIndex = e.RowIndex; Id_hfd.Value = User_grd.DataKeys[User_grd.EditIndex].Value.ToString(); UpdateVoterTableAdapter VT = new UpdateVoterTableAdapter(); object Chk = VT.DeleteCandidate(Id_hfd.Value); bool chk = Convert.ToBoolean(Chk); if (chk == true) { User_grd.DataBind(); ScriptManager.RegisterStartupScript(this, this.GetType(), "popup", "alert('Voter deleted successfully.');window.location='EditRemoveCandidate.aspx';", true); } else { ScriptManager.RegisterStartupScript(this, this.GetType(), "popup", "alert('Voter deletion Failed');window.location='EditRemoveCandidate.aspx';", true); } }
protected void btnSave_Click(object sender, EventArgs e) { UpdateVoterTableAdapter VT = new UpdateVoterTableAdapter(); string dateString = DOBpnl_txt.Text; string format = "dd/mm/yyyy"; DateTime dateTime = DateTime.ParseExact(dateString, format, CultureInfo.InvariantCulture); string strNewDate = dateTime.ToString("yyyy-dd-mm"); object Chk = VT.UpdateVoter(ID.Text, VoterName_txt.Text, VoterFname_txt.Text, VoterGender_txt.Text, strNewDate, Emailpnl_txt.Text, Contactpnl_txt.Text); bool CHECK = Convert.ToBoolean(Chk); if (CHECK == true) { User_grd.DataBind(); ScriptManager.RegisterStartupScript(this, this.GetType(), "popup", "alert('Voter Updated successfully.');window.location='UserList.aspx';", true); } else { ScriptManager.RegisterStartupScript(this, this.GetType(), "popup", "alert('Voter Updation Failed');window.location='UserList.aspx';", true); } }