Question : How can I databind with a default entry of string.Empty

I have a number of databound controls but I have been unable to get the databindings to initialise to an empty string on null.

I am connecting them to an adapter and as a temporary measure have set the default to a space which at least works, but if I set it to string.Empty or "" I get an error from the database.

The space is causing problems because users fail to deleted the space which stuffs the indexing as they don't think to try a space first when searching...

Any suggestipns?

Chris Bray
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
// Works, but leaves a space that causes problems... 
linkedFileControl.fileNameTextBox.DataBindings.Add("Text", linkedFilesBindingSource, "FileName", true, DataSourceUpdateMode.OnPropertyChanged, " ");


// Fails
linkedFileControl.fileNameTextBox.DataBindings.Add("Text", linkedFilesBindingSource, "FileName", true, DataSourceUpdateMode.OnPropertyChanged, "");


// Fails
linkedFileControl.fileNameTextBox.DataBindings.Add("Text", linkedFilesBindingSource, "FileName", true, DataSourceUpdateMode.OnPropertyChanged, string.Empty);

Answer : How can I databind with a default entry of string.Empty

Try the Load Optimized Defaults first., If that doesn't work try the other one. Good luck.
Random Solutions  
 
programming4us programming4us