protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e) { Label lblActivityTypeID = GridView1.Rows[e.RowIndex].FindControl("lblActivityTypeID") as Label; TextBox txtTitle = GridView1.Rows[e.RowIndex].FindControl("txtTitle") as TextBox; if (lblActivityTypeID != null && txtTitle != null) { ActivityType activityType = new ActivityType(); activityType.ActivityTypeID = Convert.ToInt32(lblActivityTypeID.Text.Trim()); activityType.Title = txtTitle.Text; //Let us now update the database if (activityTypeHandler.Update(activityType) == true) { lblResult.Text = "Record Updated Successfully"; } else { lblResult.Text = "Failed to Update record"; } //end the editing and bind with updated records. GridView1.EditIndex = -1; BindData(); } }
protected void btnYES_Click(object sender, EventArgs e) { ActivityType activityType = new ActivityType(); ActivityTypeHandler activityTypeHandler = new ActivityTypeHandler(); string activityTypeID = Request.QueryString["activityTypeID"] as string; activityType.ActivityTypeID = Convert.ToInt32(activityTypeID); activityType.Title = txtTitle.Text; activityTypeHandler.Update(activityType); Response.Redirect("Z_ActivityTypeDefault.aspx"); }