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
746
Programatically Add Rows to Datasource problem
posted

I have a xamdatagrid with an ado.net Dataset bound to it.  When I attempt to add new rows to the underlying dataset (e.g. table.newrow()   table.rows.Add(newrow))  I get a runtime exception stating that the row i am trying to add belongs to another table.  The status of the row is detached.  I made sure the table I created the new row from is the same table as the one i'm trying to add it to.  Is this expected behavior with the grid?  How can I programaticallly add a new row to the grid?  Thanks.

Parents
No Data
Reply
  • 440
    posted

    Hi,

    I couldn't reproduce your problem. The error you described is more likely to be related to misspelling in the names of the tables(e.g. table1.newrow()   table.rows.Add(newrow)).

    To test this - you can download xamFeatureBrowser (http://xamples.infragistics.com/) and in the samples under xamDataGrid->Layout and Behavior there is a sample Add Record. To test your case just add this code snippet in the end of the AddRecord_Samp_Loaded

     

     

    DataRow DR = ds.Tables[0].NewRow();

    DR[

     

    "Title"] = "NEW TITLE";

    ds.Tables[0].Rows.Add(DR);

Children
No Data