Newbie question - I'm using a dropdownlist on a web form. The dropdown is populated from a view which contains possible values for the field with the exception of a null value (empty string).
The database allows nulls in these fields, and the field is set up within the Business Object Mapper to "Use nullable generic".
All fields that have a non-null value are binding and displaying correctly when the page loads. However, when the value is null, I'd like the user to see that there is no value for the field by seeing a blank dropdown when the page first loads for editing. So far, though, I haven't been able to do this. What I see when the page first loads is the first value of the dropdown list as defined by the view that populates the list of potential values.
I'm sure I'm just missing something simple -- any ideas?
Mark
In this case I would use a "Return alternate value on NULL" and return an empty string. At preset you indicated you are using a Nullable Generic...this is another type class. So it does not return a String type, but rather a Nullable type. If you change this to Return Alternate value on Null and then return an empty string: "" or String.Empty then you should have a much easier time moving forward.
Trent -
Thanks for your quick response.
The reason I was using a nullable generic is because the value associated with my dropdown field is a GUID. If I change to "Return Alternate value on Null" or either of the "Return Alternate on Null / Set Null on Alternate" variations, they generate a build error "Cannot implicitly convert type 'string' to GUID" at the following section of code:
set { if (value != String.Empty) { this.CurrentRow["uAffiliationID"] = value; } else { this.CurrentRow["uAffiliationID"] = DBNull.Value; } }}
Given this, I'm still not sure what the correct way to implement the dropdown is.
Yours,
new Guid("00000000-0000-0000-0000-000000000000")
Then, in the TopMostValue of the combo box, put the value as 00000000-0000-0000-0000-000000000000. There is a GuidTypeConverter that should convert he string representation of the value into the proper Guid value.
Hope that helps.