//Method to Fill Completed lists into Grid View protected void FillGridView() { try { TodoListBusinessObject obj_TodoListBO = new TodoListBusinessObject(); obj_TodoListBO.EmailID = (string)Session["EmailID"]; TodoListBusinessLogicFactory obj_UserTodoListBLF = new TodoListBusinessLogicFactory(); DataSet coll = obj_UserTodoListBLF.CreateTodoListBLF().GetUserArchiveBL(obj_TodoListBO); if (coll != null) { UserArchiveGridView.DataSource = coll.Tables["TodoList_UserLists"]; UserArchiveGridView.DataBind(); } else { DataTable dt = new DataTable(); UserArchiveGridView.DataSource = dt; UserArchiveGridView.DataBind(); } } catch { ErrorLabel.Text = "Error Filling GridView"; } }
//Event to delete selected List protected void DeleteButton_Click(object sender, EventArgs e) { try { foreach (GridViewRow gvslrow in UserArchiveGridView.Rows) { CheckBox chek = (CheckBox)gvslrow.FindControl("SelectCheckBox"); if (chek != null && chek.Checked) { ErrorLabel.Visible = false; TodoListBusinessObject obj_DeleteListBO = new TodoListBusinessObject(); obj_DeleteListBO.EmailID = (String)Session["EmailID"]; obj_DeleteListBO.IsArchive = false; foreach (GridViewRow gvslkrow in UserArchiveGridView.Rows) { CheckBox chk = (CheckBox)gvslkrow.FindControl("SelectCheckBox"); if (chk != null && chk.Checked) { obj_DeleteListBO.Title = gvslkrow.Cells[1].Text; obj_DeleteListBO.Description = gvslkrow.Cells[2].Text; ErrorLabel.Visible = false; foreach (GridViewRow grid in UserArchiveGridView.Rows) { CheckBox uncheck = (CheckBox)grid.FindControl("SelectCheckBox"); uncheck.Enabled = false; } } else { ErrorLabel.Text = "Please Select a Item to Delete"; ErrorLabel.Visible = true; } } TodoListBusinessLogicFactory objDeleteBLLFactRow = new TodoListBusinessLogicFactory(); objDeleteBLLFactRow.CreateTodoListBLF().DeleteUserListBL(obj_DeleteListBO); TodoListBusinessObject obj_TodoListBO = new TodoListBusinessObject(); obj_TodoListBO.EmailID = (string)Session["EmailID"]; TodoListBusinessLogicFactory obj_UserTodoListBLF = new TodoListBusinessLogicFactory(); DataSet coll = obj_UserTodoListBLF.CreateTodoListBLF().GetUserArchiveBL(obj_TodoListBO); if (coll != null) { UserArchiveGridView.DataSource = coll.Tables["TodoList_UserLists"]; UserArchiveGridView.DataBind(); } else { DataTable dt = new DataTable(); UserArchiveGridView.DataSource = dt; UserArchiveGridView.DataBind(); } } else { ErrorLabel.Text = "Please Select a Item to Delete"; ErrorLabel.Visible = true; } } } catch { ErrorLabel.Text = "Unable to load Delete Button"; } }