none
Formatting data before binding RRS feed

  • Question

  • Hello,

    I have a business object returning a datatable back to a bindingsource, which a datagridview uses to bind the results.  However, certain fields are yes/no, which I want to convert to true/false.  Is there an event that fires before the binding takes place where I can switch it?

    Thanks.

    Tuesday, January 3, 2006 6:17 PM

All replies

  • There are several approaches you can take here:

    • Use the System.Windows.Forms.Binding class (extensive usage examples are included in the documentation for it). It features a Format event that does exactly what you want (and a Parse event for conversions the other way around);
    • Write a SQL stored procedure to return the data in the correct format;
    • Use an ObjectDataSource -- this is the most work, but will allow you to go absolutely crazy, customization-wise

    '//mdb

     

    Tuesday, January 3, 2006 7:22 PM
  • For your purposes, Binding.Format is probably the best bet.
    Tuesday, January 3, 2006 11:11 PM