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

[Solved] Grid remains in edit mode after my value has been updated

3 Answers 114 Views
Grid
This is a migrated thread and some comments may be shown as answers.
W
Top achievements
Rank 1
W asked on 30 Jan 2009, 04:09 PM
Hi All,

I'm editng a grid inline using the ExtractValuesFromItem method as described in your documentation. However, when the update has finished the grid remains in edit mode. How can I end the edit mode in this instance? Here is my code:

protected void radgridNetCosts_UpdateCommand(object source, GridCommandEventArgs e)
    {
        GridEditableItem item = (GridEditableItem)e.Item;
        int bookingTransactionID = int.Parse(item["BookingTransactionID"].Text);
        Dictionary<string, string> dictionary = new Dictionary<string, string>();
        
        radgridNetCosts.MasterTableView.ExtractValuesFromItem(dictionary, item);
        UpdatedSupplierCostsItem(radgridNetCosts, dictionary["SupplierReference"], bookingTransactionID);
    }

    private void UpdatedSupplierCostsItem(RadGrid radGrid, string supplierReference, int bookingTransactionID)
    {
        // connection string
        string cs = ConfigurationManager.ConnectionStrings["mcsQCConnectionString"].ConnectionString;
        SqlConnection conn = new SqlConnection(cs);

        // SQL Command
        SqlCommand command = new SqlCommand("UpdateSupplierCostsItem", conn);
        // Specify Command Type
        command.CommandType = CommandType.StoredProcedure;

        //Setup and assign parameters if needed
        command.Parameters.Add("@SupplierReference", SqlDbType.VarChar, 50).Value = supplierReference;
        command.Parameters.Add("@BookingTransactionID", SqlDbType.Int).Value = bookingTransactionID;

        try
        {
            conn.Open();
            command.ExecuteNonQuery();
        }

        catch (Exception ex)
        {
            // handle exception
        }
        finally
        {
            if (conn.State != null)
            {
                conn.Close();
            }
        }
    }

Thanks!

3 Answers, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 30 Jan 2009, 04:15 PM
Hello Imran,

The most common reason for this behavior is when you set AllowAutomaticUpdates="true" in the declaration of your RadGrid. Please let us know whether this helps.

Best regards,
Daniel
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
W
Top achievements
Rank 1
answered on 02 Feb 2009, 09:16 AM
Daniel,

Yes that works.

Thanks for the quick response!
0
ibrahim
Top achievements
Rank 1
answered on 03 May 2009, 08:38 AM
i had the same problem and what you sugested i got "Failed to load viewstate.  The control tree into which viewstate is being loaded must match the control tree that was used to save viewstate during the previous request.  For example, when adding controls dynamically, the controls added during a post-back must match the type and position of the controls added during the initial reque" and not when i press updated once but twice
Tags
Grid
Asked by
W
Top achievements
Rank 1
Answers by
Daniel
Telerik team
W
Top achievements
Rank 1
ibrahim
Top achievements
Rank 1
Share this question
or