This is a migrated thread and some comments may be shown as answers.

Edit User Control retaining values

1 Answer 66 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Chris
Top achievements
Rank 1
Chris asked on 08 Jul 2011, 04:52 PM
Good morning, dear Telerik wizards,

Simple scenario.. RadGrid showing fine. On particular context menu click, opening via popup one of a number of DIFFERENT edit user controls. For example:
RGVMyTasksAll.MasterTableView.EditFormSettings.UserControlName = "MemberITaskDelete.ascx";
RGVMyTasksAll.MasterTableView.EditFormSettings.PopUpSettings.Width = 400;
sEditTUID = RGVMyTasksAll.Items[radGridClickedRowIndex].Cells[2].Text;
tName = RGVMyTasksAll.Items[radGridClickedRowIndex].Cells[4].Text;
RGVMyTasksAll.MasterTableView.EditFormSettings.CaptionFormatString = "Deleting Task: " + tName.ToUpper();
RGVMyTasksAll.Items[radGridClickedRowIndex].Edit = true;
ck = new HttpCookie("ITID", sEditTUID);
Response.Cookies.Add(ck);
RGVMyTasksAll.MasterTableView.AllowAutomaticInserts = false;
RGVMyTasksAll.MasterTableView.AllowAutomaticUpdates = false;
RGVMyTasksAll.Rebind();
break;
Probably don't need all of those lines in there... but when the Rebind is executed,the user control pops up just fine. This particular one is focussed on gathering adequate permissions before delete of task is authorized. Delete in this case is NOT a delete of record, but a change of status of a record... so it is really an update.

When done, I get the popup to go away by:
RadGrid rg = (RadGrid)CMFinds.FindControl(p, "RGVMyTasksAll");
rg.AllowAutomaticInserts = false; rg.AllowAutomaticUpdates = false; rg.AllowAutomaticDeletes = false;
rg.MasterTableView.AllowAutomaticInserts = false; rg.MasterTableView.AllowAutomaticUpdates = false; rg.MasterTableView.AllowAutomaticDeletes = false;
rg.MasterTableView.IsItemInserted = false;
rg.MasterTableView.ClearChildEditItems();
rg.Rebind();
My own (better for many complex situations) recursive Find Control locates the calling grid... again not sure that I need all the lines... but it closes, delete (which is change of state) is accomplished earlier, all is well.

Problem: Next time I come in to do another delete, the popup user control contains the data from the PRIOR delete, not the current one.

So two questions:
1. How can I make sure the edit control either unloads inbetween calls or resets the data properly? Important
2. What can I delete from this code as unnecessary? Just out of curiosity.

Thanks.
Chris

1 Answer, 1 is accepted

Sort by
0
Mira
Telerik team
answered on 14 Jul 2011, 08:19 AM
Hello Chris,

Please examine the User Control Edit Form demo and help topic to see how the desired functionality can be implemented.
You can safely remove the disabling of the automatic operations of the grid from your code - for example you can set it only declaratively.
If the issue persists, please send us the code of the usercontrol. Isolating the problem in a sample project will be highly appreciated.

I hope this helps.

Best wishes,
Mira
the Telerik team

Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

Tags
Grid
Asked by
Chris
Top achievements
Rank 1
Answers by
Mira
Telerik team
Share this question
or