StrataFrame Forum
Home      Members   Calendar   Who's On
Welcome Guest ( Login | Register )
      



Dropdown list - null valueExpand / Collapse
Author
Message
Posted 05/29/2007 7:12:46 AM
StrataFrame Beginner

StrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame Beginner

Group: StrataFrame Users
Last Login: 09/11/2008 3:47:09 PM
Posts: 34, Visits: 9,938
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

Post #9131
Posted 05/29/2007 7:53:36 AM


StrataFrame Developer

StrataFrame Developer

Group: StrataFrame Developers
Last Login: Yesterday @ 5:04:58 PM
Posts: 4,780, Visits: 4,744
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.

Post #9132
Posted 05/29/2007 8:37:52 AM
StrataFrame Beginner

StrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame Beginner

Group: StrataFrame Users
Last Login: 09/11/2008 3:47:09 PM
Posts: 34, Visits: 9,938
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

Post #9136
Posted 05/29/2007 8:41:38 AM


StrataFrame Developer

StrataFrame Developer

Group: StrataFrame Developers
Last Login: 10/21/2008 9:20:58 AM
Posts: 2,685, Visits: 1,887
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.


www.bungie.net
Post #9137
« Prev Topic | Next Topic »


Reading This TopicExpand / Collapse
Active Users: 0 (0 guests, 0 members, 0 anonymous members)
No members currently viewing this topic.
Forum Moderators: Ben Chase, Trent L. Taylor, Steve L. Taylor

PermissionsExpand / Collapse

All times are GMT -6:00, Time now is 6:09am

Powered by InstantForum.NET v4.1.4 © 2008
Execution: 0.078. 13 queries. Compression Enabled.
Site Map - Home - My Account - Forum - About Us - Contact Us - Try It - Buy It

Microsoft, Visual Studio, and the Visual Studio logo are trademarks or registered trademarks of Microsoft Corporation in the United States and/or other countries.