delete-rowdatarowrowstate

DataRow which is added is not going to be delete doing table.Rows[i].Delete()?


Why is that? The state of the datarow is added. When I delete the row the state is unchanged. Why not deleted? That's the reason my Delete Store Procedure is never called!

edit: the datarow is freshly added and then I try to delete it.


Solution

  • show your code please. my test shows that everything works fine:

            DataTable dt = new DataTable();
            DataRow dr = dt.NewRow();
            dt.Rows.Add(dr);
            Console.WriteLine(dr.RowState);
            dr.Delete();
            Console.WriteLine(dr.RowState);
    

    output is:

            Added
            Detached