//Handle the delete button click event public void ArticleComments_RowCommand(object sender, GridViewCommandEventArgs e) { if ((e.CommandName == "DeleteComment")) { //Passing multiple command argument separated by comma so we can split it. string[] commandArgsDelete = e.CommandArgument.ToString().Split(new char[] { ',' }); int COMID = int.Parse(commandArgsDelete[0].ToString()); // Get the Comment ID int RecID = int.Parse(commandArgsDelete[1].ToString()); // Get the Lyric ID ArticleCommentsRepository comment = new ArticleCommentsRepository(); comment.ID = COMID; comment.RECID = RecID; comment.Delete(comment); comment = null; Response.Redirect("articlecommentconfirmation.aspx?mode=del&id=" + COMID); } if ((e.CommandName == "EditComment")) { //Passing multiple command argument separated by comma so we can split it. string[] commandArgsEdit = e.CommandArgument.ToString().Split(new char[] { ',' }); int CID = int.Parse(commandArgsEdit[0].ToString()); // Get the Comment ID string strComment = commandArgsEdit[1].ToString(); // Get the Comment Panel1.Visible = true; KeyIDs.Value = CID.ToString(); Comments.Text = strComment; lblheaderform.Text = "Updating Comment #: " + CID; } else { Panel1.Visible = false; } }
public void DeleteAllSelectedItems_Click(object sender, EventArgs e) { Panel1.Visible = false; for (int i = 0; i < ArticleComments.Rows.Count; i++) { CheckBox chkID = ArticleComments.Rows[i].FindControl("chkDelete") as CheckBox; if (chkID.Checked) { int ComID = int.Parse(ArticleComments.Rows[i].Cells[3].Text.ToString()); int RecID = int.Parse(ArticleComments.Rows[i].Cells[4].Text.ToString()); ArticleCommentsRepository comment = new ArticleCommentsRepository(); comment.ID = ComID; comment.RECID = RecID; comment.Delete(comment); } } Response.Redirect("articlecommentconfirmation.aspx?mode=DeleteAll"); }