none
typed datatable and cell changed event RRS feed

  • Question

  •  

    I want to validate my data at the typed dataset level and not at the datagridview / ui level. Data validation is a business rule and as such should be a different layer then the UI.

     

    At the typed dataset level, I want to validate what gets modified there and what doesn't. I only see a row changed event on each typed datatable and not a cell changed event. What is the correct pattern to apply when I need to validate changes based on each cell of a row. So, I need to know what the original value of a cell and the proposed value of the cell is... Is it possible to gather this information and if so how through the typed dataset object?

     

    I guess perhaps what I'm looking for is a datacell object. In the datarowchanging event of a datatable, you should be able to find out for each cell if anything has changed and handle it appropriately.

    Thursday, October 11, 2007 9:32 PM

Answers

  • DataTable does have a ColumnChanging event; http://msdn2.microsoft.com/en-us/library/d133hta4.aspx

     

    The DataSet designer does not build a strongly-typed wrapper for this event.

     

    You could create a handler for the Initialized event of the DataSet.  Within that handler, use AddHandler (VB.NET) or += (C#) to attach your routine to the DataChanging event.  The page referenced above gives an example of using the event.

     

     

    Saturday, October 13, 2007 11:41 PM