Deleting row from DataView (OT)

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Derrick

    Deleting row from DataView (OT)

    Hello;

    Sorry for being a little off topic. I've posted to the ADO.NET group as
    well :)

    Dealing with Winforms on 1.1 framework, VS.NET 2003.

    I have a DataView (which is the Data Source for a DataGrid), and I want to
    be able to delete rows only if specific columns contain specific values.
    For example, one of the columns contains boolean values; if the value for
    the row we are attempting to delete is true go ahead and delete it, but if
    it's false cancel the delete.

    I have a handler hooked to the DataTable.RowDe leting event (the DataTable is
    obviously the source for my DataView), which supposedly fires before the row
    is deleted. In there, I check my column conditions, but what I need to know
    is what do I call to cancel the deletion? I've tried DataRow.RejectC hanges,
    DataRow.CancelE dit, and DataTable.Rejec tChanges to no avail - the row always
    disappears from the DataGrid, so I assume the row is being deleted from the
    view. I step through the event, so it is being triggered and my condition
    checking is accurate.

    I also tried doing stuff in the DataView.ListCh anged

    Thanks for your help;

    Derrick


  • Nicholas Paldino [.NET/C# MVP]

    #2
    Re: Deleting row from DataView (OT)

    Derrick,

    Instead of allowing people to delete through the data view/data table,
    why not create a wrapper for accessing the rows (or at least, performing
    actions on the rows) which will not perform the delete in the first place.

    Then, you route all the calls through that.

    Also, have you tried throwing an exception? This might be the only way
    to get the operation to cancel.

    Hope this helps.


    --
    - Nicholas Paldino [.NET/C# MVP]
    - mvp@spam.guard. caspershouse.co m

    "Derrick" <derrick_dunne@ hotmail.com> wrote in message
    news:Ketcf.1458 8$1L3.608742@ne ws20.bellglobal .com...[color=blue]
    > Hello;
    >
    > Sorry for being a little off topic. I've posted to the ADO.NET group as
    > well :)
    >
    > Dealing with Winforms on 1.1 framework, VS.NET 2003.
    >
    > I have a DataView (which is the Data Source for a DataGrid), and I want to
    > be able to delete rows only if specific columns contain specific values.
    > For example, one of the columns contains boolean values; if the value for
    > the row we are attempting to delete is true go ahead and delete it, but if
    > it's false cancel the delete.
    >
    > I have a handler hooked to the DataTable.RowDe leting event (the DataTable
    > is obviously the source for my DataView), which supposedly fires before
    > the row is deleted. In there, I check my column conditions, but what I
    > need to know is what do I call to cancel the deletion? I've tried
    > DataRow.RejectC hanges, DataRow.CancelE dit, and DataTable.Rejec tChanges to
    > no avail - the row always disappears from the DataGrid, so I assume the
    > row is being deleted from the view. I step through the event, so it is
    > being triggered and my condition checking is accurate.
    >
    > I also tried doing stuff in the DataView.ListCh anged
    >
    > Thanks for your help;
    >
    > Derrick
    >[/color]


    Comment

    Working...