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

RadGrid EditMode Modal Popup Not Closing And Data Not Updating

19 Answers 615 Views
Grid
This is a migrated thread and some comments may be shown as answers.
jgill
Top achievements
Rank 1
jgill asked on 21 Oct 2010, 11:45 PM
Hello, I am having a troublesome issue with the RadGrid in the PopUp Edit mode.  I have a RadGrid that allows users to enter data into the grid via the modal popup edit style form.  I'm having two issues on insert or edit (deletes work fine):
  1. The modal pop-up does not close/go away after the user inserts a record or updates it if all the fields are not filled out.  If the user populates a value for all of the fields when they insert, then the modal closes itself (the desired behavior)
  2. On updates/edits if the user changes the value in a field from having a value to not having a value (e.g. deletes out the value for the example field "Middle Name") then attempts to save that back, the modal both does not close and the update does not occur.  If the user populates a value for each field then the update occurs and the modal popup is closed on submit/save.

I have tried trapping any errors on the data grid insert, update, or delete and no errors are being caught there, so I am not sure what the issue is and am seeking help with this.  I would like the updates that change values to empty to be valid and for the modal to close itself on insert or update even if the user has not filled out values for each field.

19 Answers, 1 is accepted

Sort by
0
Marcia Marino
Top achievements
Rank 1
answered on 25 Oct 2010, 03:27 AM
Are you perfroming the Update/insert operation manually or automatically? If you are performing the operation in code behind(manually), then set the AllowAutomaticInserts/Updates to false and check if it helps close the edit popup form.
0
jgill
Top achievements
Rank 1
answered on 25 Oct 2010, 04:06 PM
Thanks, the inserts and updates as well as creation of the dataset and datatable are performed in code.  I tried setting AutomaticUpdates to False for the RadGrid (as well as the MasterTableView of the RadGrid) and the behavior stayed the same.  If I do not completely fill out all fields for the grid for insert or update the modal does not close after the action is completed and for updates, the update of the dataset/datatable for the grid does not seem to occur unless all the fields are filled out in the edit.
0
Tsvetina
Telerik team
answered on 27 Oct 2010, 07:45 AM
Hi,

Could you please check if removing the Rebind() from your insert and update command event handlers changes the behavior of RadGrid?
 
When performing inserts and updates unless you cancel the event, RadGrid calls Rebind() implicitly and if you do so, too, the edit form may not close, as it happens in this case.


All the best,
Tsvetina
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
jgill
Top achievements
Rank 1
answered on 28 Oct 2010, 05:10 PM
Thank you.  I tried removing the Rebind() calls, but a variation of the same behavior occurs (except worse as when the user INSERTS or UPDATES a row the grid does not get updated until they manually close the modal pop-up as it does not close itself).  The grid still experiences the issue that when a user does not fill in values for all the editable fields on a UPDATE, the update does not occur even when the Rebind() is not performed on the Update or Insert commands and the user manually closes the modal after attempting an UPDATE.
0
Tsvetina
Telerik team
answered on 03 Nov 2010, 09:47 AM
Hello,

In case you do not have any validators for your edit form controls, could you please confirm that the fields in your datasource are nullable? The error would be on database level in case they are not nullable and you do not fill in values for them.

All the best,
Tsvetina
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
jgill
Top achievements
Rank 1
answered on 03 Nov 2010, 06:30 PM
I do not have any validators on any of the fields.  I am however creating the datatable and dataset programatically on the Init event (the grid is actually a user control in my usage and I use Page_Init), but not explicility saying that all fields should allow nulls.  I will add that code to the thread to see if that is perhaps the issue or if the ordering of the control lifecycle events is causing an issue.
0
jgill
Top achievements
Rank 1
answered on 05 Nov 2010, 12:38 AM
Redacted.
0
Tsvetina
Telerik team
answered on 10 Nov 2010, 12:27 PM
Hello,

What about the fields in your the database you fetch the data from - are they nullable? Does the incorrect behavior occur if you create a dataset with dummy data and try to perform insert/update on it?


Regards,
Tsvetina
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
jgill
Top achievements
Rank 1
answered on 27 Dec 2010, 09:44 PM
Hello Tsvetina and Telerik Team,
I have recreated this problem using dummy data that is not loaded from a database.  You can view/experience the issues in the example sent an using the steps written below and the code for the test sample can be downloaded from the link sent.

Insert Issue
  1. Click "Add new record" in the grid
  2. Fill out data only for the first column/field (enter a random string)
  3. Click the checkmark image/insert icon
  4. Notice how the pop-up does not close
Update issue
  1. Delete any previously entered data from the grid
  2. Insert a new record and enter/populate values for all fields/columns (there are only four)
  3. Click the checkmark image/insert icon to insert the data
  4. Click the pencil/edit icon for the record you just added
  5. Change the value you entered for "FakeLocalizedValue3" so it has a new/different value
  6. Erase the value you entered for "FakeLocalizedValue1" so there is no value for the field
  7. Click the checkmark image/insert/update icon
  8. Notice how the pop-up does not close and on top of that the value for "FakeLocalizedValue1" and "FakeLocalizedValue3" remains the original value instead of the changed value
0
Maria Ilieva
Telerik team
answered on 03 Jan 2011, 10:18 AM
Hello Gill,

I tried to run the provided code locally but to no avail. Some errors regarding wrong columns cast appear in the code. Please find attached a screenshot for those errors. Revise the code on your side and provide fully runnable version so we could debug it locally and advise you further.


All the best,
Maria Ilieva
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0
jgill
Top achievements
Rank 1
answered on 03 Jan 2011, 04:18 PM
Thank you.  I am not receiving this build error from the same code, but will try to make the adjustments needed.
0
jgill
Top achievements
Rank 1
answered on 04 Jan 2011, 03:48 AM
I downloaded the code on a new machine in a newer version of Visual Studio and it ran without modification while displaying the issues mentioned above.

Is there some special debugging setting your using that is preventing the code from building that may be more strict (I am not aware of this setting change if so)? 

I am sorry, but I cannot seem to get the same build error in VS 2005, 2008, or 2010 on two machines if there is any thing you could point me to look at to change to allow it to run on your debugging machine.  I have a screenshot attached to this post of the code running where I just pulled down the code brand new onto a different from the link above and hit debug and it built/ran.

Thank you again,
0
Tsvetina
Telerik team
answered on 06 Jan 2011, 12:34 PM
Hello,

I managed to run your project and what I noticed is that the code you use to update records throws exceptions which are caught in the try-catch blocks and do not display to notify you of the problems with the operations. Please, remove the try-catch blocks to see the exceptions and see if correcting your code fixes the popup issue (as I think we mentioned before, the edit form stays open when there were problems during the edit process).

One thing you should note is that the correct way to access the values of numeric and date time column editors is:
editorValue = CType(editor, GridNumericColumnEditor).NumericTextBox.Value
editorValue = CType(editor, GridDateTimeColumnEditor).PickerControl.SelectedDate


All the best,
Tsvetina
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0
jgill
Top achievements
Rank 1
answered on 07 Jan 2011, 10:28 PM
Thank you Tsvetina.

I made the changes suggested to access the values from the Numeric and DatePicker Editors as well as removing all Try-Catch blocks. 
  • When I remove the Try-Catch blocks and attempt to INSERT data, no error is thrown but the RadGrid Modal Window does not close, but the INSERT occurs successfully
    • This seems to still be an issue as the modal is not closing on insert.
  • When I removed the Try-Catch blocks and attempted to perform an UPDATE then I received an error when any of the fields of the edited item were null, which seems to be the cause of why the updates were not occuring.  It was because I was trying to set a value to null/nothing when it should have been set to DBNull since it is a datatable value.
    • To fix this in the update I changed the following code in RadGrid1_UpdateCommand (this change, but not the try catch block removal is reflected in the sample URL that was listed in an earlier post on this thread):
For Each entry As DictionaryEntry In newValues
    If Not IsDBNull(entry.Value) AndAlso Not entry.Value Is Nothing Then
        ChangedRows(0)(DirectCast(entry.Key, String)) = entry.Value
    Else
        ChangedRows(0)(DirectCast(entry.Key, String)) = DBNull.Value
    End If
Next
0
Accepted
Tsvetina
Telerik team
answered on 12 Jan 2011, 12:19 PM
Hello,

If you are sure that the insert takes place without problems and your database is updated correctly, you can close the edit form by adding a line that does so at the end of the InsertCommand event handler and rebind the grid afterwards:
RadGrid1.MasterTableView.IsItemInserted = False
RadGrid1.Rebind()

Regards,
Tsvetina
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0
Jason Sheats
Top achievements
Rank 1
answered on 03 Nov 2011, 10:00 PM
I have an Update button that works fine.  Two other buttons that I created from pasting those and renaming them fail to close the window.

I have validation groups attached, but when I took out the validation groups, I still had the same problem with the pop-up window remaining open.  All changes were reflected in the database and no error messages are being thrown in the C# code or in the browser window (little javascript error icon in the bottom left does not appear as well as no pop-ups).

Could it be the copying of the RadButtons?

I noticed that after I click the working Update button, the NeedDataSource method is called for the grid.  After clicking either of the other 2 buttons, the NeedDataSource method is NOT called.

What could cause that?

I will use the method below:
RadGrid1.MasterTableView.ClearEditItems(); 
RadGrid1.Rebind()


But I'm interested in another way to solve this problem.  I will probably delete the RadButtons and re-drag them onto the form from the toolbox. 

Update:
ClearEditItems() followed by Rebind() worked.
0
Tsvetina
Telerik team
answered on 04 Nov 2011, 04:48 PM
Hi Jason,

I am not sure I fully understand the problem, can you please paste the mark-up and the client code related to the issue?

Best wishes,
Tsvetina
the Telerik team
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 their blog feed now
0
Erik
Top achievements
Rank 2
answered on 17 Jun 2014, 01:25 PM
Hi,

This behavior changed since Q1 .403 vs Q1 .225 ?

I have a production version (2014 Q1 .0225) that closes the radGrid popup dialog on save, but in my development version (2014 Q1 .0403) the dialog does not close on save.

Erik
0
Milena
Telerik team
answered on 20 Jun 2014, 10:37 AM
Hello Eric,

Could you please try to replicate the issue on this live example and provide us exact steps for reproduce? You can also provide us some sample markup, which we will use to simulate your scenario and investigate the issue locally.

Regards,
Milena
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Grid
Asked by
jgill
Top achievements
Rank 1
Answers by
Marcia Marino
Top achievements
Rank 1
jgill
Top achievements
Rank 1
Tsvetina
Telerik team
Maria Ilieva
Telerik team
Jason Sheats
Top achievements
Rank 1
Erik
Top achievements
Rank 2
Milena
Telerik team
Share this question
or