Dropdown list - null value


Author
Message
StrataFrame Team
S
StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
You should be able to use the Return Alternate on Null / Set Null on Alternate and return and use this as your replacement value:

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.

Mark Dowlearn
Mark Dowlearn
StrataFrame Beginner (46 reputation)StrataFrame Beginner (46 reputation)StrataFrame Beginner (46 reputation)StrataFrame Beginner (46 reputation)StrataFrame Beginner (46 reputation)StrataFrame Beginner (46 reputation)StrataFrame Beginner (46 reputation)StrataFrame Beginner (46 reputation)StrataFrame Beginner (46 reputation)
Group: Forum Members
Posts: 34, Visits: 9.9K
Trent L. Taylor (05/29/2007)
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:

/// <summary>
/// uAffiliationID
/// </summary>
/// <remarks></remarks>
[Browsable(false),
BusinessFieldDisplayInEditor(),
Description("uAffiliationID"),
DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public System.Guid uAffiliationID
{
   get
   {
      object loValue;
      loValue =
this.CurrentRow["uAffiliationID"];
      if (loValue == DBNull.Value)
      {
      return String.Empty;
      }
   else
      {
      return (System.Guid)loValue;
      }
   }

   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,

Mark


Trent Taylor
Trent Taylor
StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
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.

Mark Dowlearn
Mark Dowlearn
StrataFrame Beginner (46 reputation)StrataFrame Beginner (46 reputation)StrataFrame Beginner (46 reputation)StrataFrame Beginner (46 reputation)StrataFrame Beginner (46 reputation)StrataFrame Beginner (46 reputation)StrataFrame Beginner (46 reputation)StrataFrame Beginner (46 reputation)StrataFrame Beginner (46 reputation)
Group: Forum Members
Posts: 34, Visits: 9.9K
Hello,

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

GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search