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

Radgrid stays in edit mode after insertcommand

3 Answers 508 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Andreas N.
Top achievements
Rank 2
Andreas N. asked on 12 Aug 2009, 08:37 PM
Hi,

my grid - not ajaxified - stays in edit mode after inserting.

No exceptions are thrown.

The updatecommand does literally the same, except for getting the edited row, and the grid reverts back to display mode.

Any suggestions are welcome

Thank you

Andreas

        protected void rgdViStore_InsertCommand(object source, GridCommandEventArgs e)
        {
            GridEditableItem editedItem = e.Item as GridEditableItem;
            DataTable substanceTable = this.substanceSource;

            storeData.VISTORE_V_EDIT_DISPLAYRow currentRow = (storeData.VISTORE_V_EDIT_DISPLAYRow)substanceTable.NewRow();

            try
            {
                // start editing
                currentRow.BeginEdit();
                // shared code for insert and update, does not fire exception
                // uses ExcractValues and gets the values from the template columns
                persistChanges(editedItem, currentRow);
                currentRow.EndEdit();
                substanceTable.Rows.Add(currentRow);
               this.substanceSource = (storeData.VISTORE_V_EDIT_DISPLAYDataTable)substanceTable;
                rgdViStore.EditIndexes.Clear();
                rgdViStore.Rebind();

            }
            catch (Exception ex)
            {
                currentRow.CancelEdit();
                rgdViStore.EditIndexes.Clear();
                rgdViStore.Rebind();
                e.Canceled = true;
            }

        }

3 Answers, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 2
answered on 13 Aug 2009, 05:31 AM
Hi Andreas,

I am not sure why you have written the code to edit/update a row in the Insert command. Can you also check whether you have enabled AllowAutomaticUpdates/AllowAutomaticInserts to true by chance. If so try setting it to false and see whether it helps.

Shinu
0
Andreas N.
Top achievements
Rank 2
answered on 13 Aug 2009, 06:47 AM
Hi Shinu,

thanks for that. AllowAutomaticInserts was still in the markup.

You mention, that there is an alternative to inserting a row into the datasource; to progress in understanding the Radgrid...

I use advanced Databinding, and a declaratively built Radgrid with TemplateColumns and GridBoundColums, what method would you suggest?


Thanks

Andreas
0
Tsvetoslav
Telerik team
answered on 14 Aug 2009, 10:39 AM
Hello Andreas N.,

The alternative that your question touches is the RadGrid control's Automatic Operations. They are meaningful only in scenarios where you have the grid bound to a data source object. In that case, the data source object's update/insert/delete commands will be automatically invoked by the grid and hence the name Automatic Operations. More information, you can find at the following online example and the related help topics:
http://demos.telerik.com/aspnet-ajax/grid/examples/dataediting/alleditablecolumns/defaultcs.aspx

In your case, however, when binding the grid to a custom data source, Automatic Operations are not possible.

I hope this helps.

Regards,
Tsvetoslav
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Grid
Asked by
Andreas N.
Top achievements
Rank 2
Answers by
Shinu
Top achievements
Rank 2
Andreas N.
Top achievements
Rank 2
Tsvetoslav
Telerik team
Share this question
or