protected void Button1_Click(object sender, EventArgs e) { if (Button1.Text == "Submit") { if (Page.IsValid) { nszillow.clslocprp objprp = new nszillow.clslocprp(); nszillow.clsloc obj = new nszillow.clsloc(); objprp.locctycod = Convert.ToInt32(DropDownList1.SelectedValue); objprp.locnam = TextBox1.Text; objprp.loccrd = Coordinates; obj.Save_Rec(objprp); GridView1.DataBind(); clear_all(); } } if (Button1.Text == "Update") { nszillow.clslocprp objprp = new nszillow.clslocprp(); nszillow.clsloc obj = new nszillow.clsloc(); objprp.loccod = Convert.ToInt32(GridView1.DataKeys[GridView1.EditIndex].Value); objprp.locctycod = Convert.ToInt32(DropDownList1.SelectedValue); objprp.locnam = TextBox1.Text; objprp.loccrd = Coordinates; obj.Update_Rec(objprp); GridView1.DataBind(); Button1.Text = "Submit"; clear_all(); } }
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "deleteRow") { nszillow.clslocprp objprp = new nszillow.clslocprp(); nszillow.clsloc obj = new nszillow.clsloc(); objprp.loccod = Convert.ToInt32(e.CommandArgument); try { obj.Delete_Rec(objprp); } catch (SqlException exp) { if (exp.Class == 16) { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('Error: Cannot Delete Location! As Location is Not Null ')", true); } } GridView1.DataBind(); clear_all(); } }