private void GrdToDoAdd() { if (ValidateToDoFooter()) { Page.Validate("activityDataNew"); if (Page.IsValid) { int employeeId = 0; EmployeeGateway employeeGateway = new EmployeeGateway(); string dateTime_ = ((TextBox)grdToDoList.FooterRow.FindControl("tbxDateTimeNew")).Text; string comment = ((TextBox)grdToDoList.FooterRow.FindControl("tbxCommentsNew")).Text; string type_ = ""; string employeeFullName = ""; GridViewRow row = grdToDoList.FooterRow; DropDownList action = ((DropDownList)row.FindControl("ddlActionsNew")); switch (action.SelectedValue) { case "Assign To User": employeeId = Int32.Parse(((DropDownList)grdToDoList.FooterRow.FindControl("ddlAssignToTeamMemberNew")).SelectedValue); employeeGateway.LoadByEmployeeId(employeeId); employeeFullName = employeeGateway.GetFullName(employeeId); type_ = "AssignUser"; hdfToDoListState.Value = "In Progress"; break; case "Add Comment": int loginId = Convert.ToInt32(Session["loginID"]); employeeId = employeeGateway.GetEmployeIdByLoginId(loginId); type_ = "AddComment"; employeeFullName = employeeGateway.GetFullName(employeeId); hdfToDoListState.Value = "In Progress"; break; case "Complete": employeeId = Int32.Parse(hdfAssignedUser.Value); employeeGateway.LoadByEmployeeId(employeeId); employeeFullName = employeeGateway.GetFullName(employeeId); type_ = "CloseToDo"; hdfCompleted.Value = "True"; hdfToDoListState.Value = "Completed"; break; case "Put On Hold": int loginIdOnHold = Convert.ToInt32(Session["loginID"]); employeeId = employeeGateway.GetEmployeIdByLoginId(loginIdOnHold); type_ = "OnHoldToDo"; employeeFullName = employeeGateway.GetFullName(employeeId); hdfToDoListState.Value = "On Hold"; break; } // static values int toDoId = Int32.Parse(hdfToDoId.Value); int companyId = Int32.Parse(hdfCompanyId.Value); bool inDatabase = false; ToDoListInformationBasicInformation generalModel = new ToDoListInformationBasicInformation(toDoListInformationTDS); generalModel.UpdateState(toDoId, hdfToDoListState.Value); ToDoListInformationActivityInformation model = new ToDoListInformationActivityInformation(toDoListInformationTDS); model.Insert(toDoId, employeeId, type_, DateTime.Parse(dateTime_), comment, false, companyId, inDatabase, employeeFullName); Session.Remove("activityInformationDummy"); Session["toDoListInformationTDS"] = toDoListInformationTDS; grdToDoList.DataBind(); } } }