grid update w/ edit form

2 posts, 0 answers
  1. ToltingColtAcres
    ToltingColtAcres avatar
    83 posts
    Member since:
    Nov 2010

    Posted 24 May 2012 Link to this post

    I have implemented this project as a test project:

    http://www.telerik.com/help/aspnet-ajax/grid-updating-inplace-and-editforms.html

    When I edit records, the edits show up in the grid... but they do not update in the northwinds database.

    How do I get the updated records to write to the northwinds mdb using this code example?
  2. ToltingColtAcres
    ToltingColtAcres avatar
    83 posts
    Member since:
    Nov 2010

    Posted 24 May 2012 Link to this post

    Figured this out. Had to add the following routine to the code:
    private Boolean WriteTable()
    {
        using (OleDbConnection conn = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" +
                  System.Web.HttpContext.Current.Server.MapPath("~/App_Data/Nwind.mdb")))
        {
            OleDbDataAdapter adapter = new OleDbDataAdapter();
            OleDbCommandBuilder builder = new OleDbCommandBuilder(adapter);
            adapter.SelectCommand = new OleDbCommand("SELECT TOP 10 OrderID, EmployeeID, OrderDate, ShipName FROM Orders", conn);
            adapter.Update(GridSource);
        }
        return true;
    }

    Then, at the end of the RadGrid1_UpdateCommand routine, I added a call to this function.

    The example code online is very misleading. I spent several hours this morning mucking around with it trying to get it to update, thinking I was doing something wrong on my end (why retrieve data from a database to a grid and then allow the user to edit it unless the changes will be applied back to the database?) The more I thought about it, the more illogical the code example seemed, since the data connection was not persistant and it was not logical to expect updates applied thru the updatecommand routine would actually send data back to the database. Once starting down that line of reasoning, finding sample code on the 'net to take a datatable and then update a backend data source was fairly simple to find. The online code examples should do a better job with comments to explain what is happening and, IMO, should include a commented out block of code such as posted above to allow the user to see how to update the backend database, if they want.

    WriteTable();

  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top