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
1140
Delete a row from Grid
posted

I am able to delete a row from the grid successfully. But when I add a new row and try to delete that row, I am unable to do it as It is not taking that row as part of the grid.selected.rows collection even though i am updating that row to the grid as soon as I created it.

Even if I try to select a group of rows, it is selecting everything except the added row. Once I update that row to the database then it is working fine. 

The method I am following while adding a row is,

add a row to the underlying datatable and then call grid.update.

Am I missing anything?

 

 

  • 469350
    Suggested Answer
    Offline posted

    nag4054 said:

    The method I am following while adding a row is,

    add a row to the underlying datatable and then call grid.update.

    This doesn't make a lot of sense. If you add a row to the grid's underlying data source, then the grid will show that row (assuming your data source is an IBindingList). Calling update on the grid commits changes from the grid to the data source, not the other way around, so adding a row to the data source and then calling Update is kinda backwards.

  • 17259
    Offline posted

    By "Add the row" do you mean that you add the row in the user interface? If so, this row is an "Add Row" and probably won't get into the selected collection. If you want to delete it just press "ESC". If you want to get it by code look in grid.ActiveRow (If it has focus).