Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
315
Missing something simple...WHDG Data Update
posted

Hi, I am just starting to use the WHDG as a evaluation measure. I got stuck with something basic. I am using the start-up solution and trying to save the data back to the Access database using the following code on RowUpdating event.

Oddly enough, after I update the data on the grid and on existing the row when I check the data in the debugger at runtime, I see the rec.Items[...].value shows the original values retrieved from the database but does not show any of the updated data I changed in UI. Can someone suggest what am I missing here?


protected void WebHierarchicalDataGrid1_RowUpdating(object sender, Infragistics.Web.UI.GridControls.RowUpdatingEventArgs e)
    {
        Infragistics.Web.UI.GridControls.GridRecord rec = e.Row;
        ContainerGrid grid = (ContainerGrid) sender;
        grid.DataKeyFields = "CategoryID";
       
        DataSet ds = new DataSet();
        OleDbConnection conn = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\Users\\Public\\Documents\\Infragistics\\NetAdvantage 2010.2\\ASP.NET\\Startup Solution\\App_Data\\Nwind.mdb");
        conn.Open();

        OleDbDataAdapter adp = new OleDbDataAdapter();
        adp.UpdateCommand = conn.CreateCommand();

        string sql = "UPDATE [Categories] SET [CategoryName] = '" + rec.Items[1].Value + "', [Description] = '" + rec.Items[2].Value + "' WHERE [CategoryID] = " + Int32.Parse(rec.Items[0].Value.ToString());

        adp.UpdateCommand.CommandText = sql;
        adp.UpdateCommand.ExecuteNonQuery();
        conn.Close();

        grid.DataSource = ds;
        grid.DataBind();
    }

Parents
No Data
Reply
  • 315
    Verified Answer
    posted

    I got it now...

    Instead of using rec.Items[0].Value, I had to use the e.Values[<boundcolumnname>].ToString() to retrieve the updated data value. Now I could use the updated values to update the database using the UpdateCommand object.

Children
No Data