// this method gets all posts from the database using CPost class
        protected void getPosts()
        {
            BusinessRules.CPost objPost = new BusinessRules.CPost();

            gvPosts.DataSource = objPost.getPosts();
            gvPosts.DataBind();
        }
        //this method deletes rows from the posts table in the database using the CPost class
        protected void gvPosts_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            BusinessRules.CPost objPost = new BusinessRules.CPost();

            objPost.deletePost(Convert.ToInt32(gvPosts.DataKeys[e.RowIndex].Values["PostID"].ToString()));
            getPosts();
        }
 protected void btnSave_Click(object sender, EventArgs e)
 {
     // Create an instance of Post and populate it with the post values and save it to the db.
     BusinessRules.CPost objPost = new BusinessRules.CPost();
     objPost.Post   = txtPost.Text;
     objPost.PostID = Convert.ToInt32(Request.QueryString["PostID"]);
     objPost.UserID = BusinessRules.CUser.getIDByName(HttpContext.Current.User.Identity.Name);
     objPost.save();
     Response.Redirect("/home.aspx", true);
 }