locked
Databinding + DBNull RRS feed

  • Question

  • Hi boarders!

    I've faced a problem using the databinding recently.
    My control uses a typed DataRow as its DataContext. The typed DataSet has been generated by Visual Studio. Some fields of that DataRow are allowed to hold NULLs.
    The control has some TextBlocks bound to various fields of the DataRow. But when some fields hold DBNull, the DataSet fails to cast it's value to the corresponding type and throws an exception. Somehow that interrupts the databinding process.
    So if a TextBlock is bound to a field which value is 123, the TextBlock's text won't be changed to an empty string after the DataContext is changed.

    Can anyone help fixing this problem? I hope I was clear enough, although I can clarify anything if I wasn't.
    Thank you
    Thursday, November 22, 2007 3:24 PM

Answers

  • There is a FallbackValue property on Binding - "{Binding Path=foo FallbackValue='''}"

     

    Does that fix the problem?

     

    Regards,

    Nick.

    Thursday, November 22, 2007 4:06 PM

All replies

  • There is a FallbackValue property on Binding - "{Binding Path=foo FallbackValue='''}"

     

    Does that fix the problem?

     

    Regards,

    Nick.

    Thursday, November 22, 2007 4:06 PM
  • Oh, thanks!!! That helped.
    Hmmm, too bad i don't pay much attention sometimes Smile And too bad VS doesn't have Intellisense in XAML "{...}" statements.
    Thursday, November 22, 2007 4:19 PM