I have a RadGrid which takes as its datasource a programmatically generated DataTable, using LINQ to SQL. When I "Decline" a "Request", the record should be deleted, however, it doesn't disappear from the grid. To clarify, the record is deleted in the database, just not in the grid itself. Here's part of the code in the ItemCommand event:
Here's the helper method for the DataSource:
I've tried it using both Rebind() and DataBind(). I can't just refresh the page, as the page actually has three grids on it, the one that is shown is decided using a dropdown and if I refresh the page the previously selected grid disappears.
if (e.CommandName == "Decline") { WellnessTeamRequest wtr = WellnessTeamRequest.FindByUserId(e.CommandArgument.ToString()); wtr.Delete(); requestsRadGrid.MasterTableView.ClearEditItems(); requestsRadGrid.DataSource = GetRequestsDS(); requestsRadGrid.DataBind(); }Here's the helper method for the DataSource:
protected DataTable GetRequestsDS() { DataTable dt = createEmptyDataSet(new string[] {"UserID", "Name", "Requested Team"}); List<WellnessTeamRequest> requests = WellnessTeamRequest.GetAllRequests(); foreach (WellnessTeamRequest request in requests) { DataRow newRow = dt.NewRow(); newRow["UserID"] = request.UserId; newRow["Name"] = request.WellnessUser.User.FullName(); newRow["Requested Team"] = request.WellnessTeam.TeamName; dt.Rows.Add(newRow); } return dt; }I've tried it using both Rebind() and DataBind(). I can't just refresh the page, as the page actually has three grids on it, the one that is shown is decided using a dropdown and if I refresh the page the previously selected grid disappears.