//protected void AddButton_Click(object sender, EventArgs e) //{ // String name = NameTextBox.Text; // String description = DescriptionTextBox.Text; // _db.Tasks.Add(new Task(projectID.Value, name, description, "new")); // _db.SaveChanges(); // //RadTaskGrid.DataSource = _db.Tasks.Where(p => p.projectId == projectID).ToList(); // RadTaskGrid.Rebind(); // Response.Redirect(Request.Url.AbsoluteUri); //} protected void RadTaskGrid_DeleteCommand(object sender, GridCommandEventArgs e) { GridDataItem item = e.Item as GridDataItem; var taskID = Convert.ToInt32(item.GetDataKeyValue("taskId")); var tasks = _db.Tasks.Where(p => p.taskId == taskID); if (tasks != null) { var userstasks = _db.UsersTasks.Where(p => p.taskId == taskID).FirstOrDefault(); if (userstasks != null) { _db.UsersTasks.Remove(_db.UsersTasks.Where(p => p.taskId == taskID).FirstOrDefault()); } _db.Tasks.Remove(_db.Tasks.Where(p => p.taskId == taskID).FirstOrDefault()); } _db.SaveChanges(); RadTaskGrid.Rebind(); }
protected void RadTaskGrid_ItemUpdated(object sender, GridUpdatedEventArgs e) { RadTaskGrid.Rebind(); }