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

[Solved] MasterTable.IsItemInserted = True, but EditItems count = 0

3 Answers 165 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Sheila
Top achievements
Rank 1
Sheila asked on 10 Jul 2013, 01:42 PM
I am trying to get to a control in the edittemplate on postback but EditItems[0] returns null.
I check MasterTableView.IsInserted and it shows true.
The grid is part of a user control that opens a new window to enable entering of a new item in order to add it to the combobox in the edit form if it does not exist.
If I skip past the code to update the combobox the grid displays with the insert form open.
The program flow is:
Main page has a grid with a user control for editing, that control will open a window with a control (page 1) containing a grid in order to add a new item to the main page combobox, the return from (page 1) will populate the combo as expected.
(page 1) can also open a window (page 2) with a user control containing a grid to add an item to the combobox on (page 1)
When (page 2) return to (page 1) the grid on (page 1) is the one that returns null for EditItems[0] but shows the grid in insert mode.
Below is the code behind:
if (Request["__EVENTTARGET"] == "wndEquipmentRental")
{
    if (Request["__EVENTARGUMENT"] != "undefined")
    {
        if (RadGrid1.MasterTableView.IsItemInserted)
        {
            GridEditFormInsertItem insItm = RadGrid1.EditItems[0] as GridEditFormInsertItem;
        }
 
        else
        {
            GridEditFormItem editItm = RadGrid1.EditItems[0] as GridEditFormItem;
        }
    }
}

3 Answers, 1 is accepted

Sort by
0
Sheila
Top achievements
Rank 1
answered on 10 Jul 2013, 08:24 PM
OK,
I made this a simple as possible,
RadGrid on a webform
The insert form has a button to open a radwindow. I open the window and return a value to the webform.
The value is returned correctly (I can see it on page_load of the webform), when I interrogate the grid on the webform; IsItemInserted is true but EditItems count is still 0.
I am checking on page_load, I also tried on pre-render but got the same result.
Why do the two properties contradict each other. At what point is the EditItems populated?
0
Sheila
Top achievements
Rank 1
answered on 10 Jul 2013, 09:43 PM
We tried to submit a support ticket but keep getting a 403 error on submit and I can't upload the sample project here.
I made this even simpler, a project with 2 webforms. a grid on one and a button on the other.
How do I submit a support ticket. I know my account does not show devcraft ultimate for some reason (something else I have to figure out) so I had my colleague Sandi submit the ticket on my behalf.
0
Kostadin
Telerik team
answered on 15 Jul 2013, 10:57 AM
Hello Sheila,

Note that when you are inserting a new row is expected the EditItems collection to be empty. In order to get the insert item you have to use the following approach.
GridEditFormInsertItem insItm = RadGrid1.MasterTableView.GetInsertItem() as GridEditFormInsertItem;

I will contact the sales department and I will notify them about the issue which you are facing with our support system.

Regards,
Kostadin
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
Tags
Grid
Asked by
Sheila
Top achievements
Rank 1
Answers by
Sheila
Top achievements
Rank 1
Kostadin
Telerik team
Share this question
or