StrataFrame Forum

Another combobox question

http://forum.strataframe.net/Topic4080.aspx

By Keith Chisarik - 11/2/2006

I am having trouble binding a combox that is populated "manually" just entering the values in the control's list. Population by BO and Enum is fine. Whenever I navigate, or change the combo value I get this....



By Trent L. Taylor - 11/2/2006

It has to do with your binding value within your data source...it has a NULL value.  Obviously you have data bound to the control...but your problem is in your population of the combo.  For example, if I wanted to populate a combo manually, I generally create an ADO.NET data table and bind it to the data source:

Dim loTable As New DataTable()

loTable.Columns.Add(New DataColumn("Display",GetType(String)))
loTable.Columns.Add(New DataColumn("Value",GetType(Integer)))

'-- Populate the table with your values

'-- Set the combo data source
MyCombo.DisplayMember = "Display"
MyCombo.ValueMember = "Value"
MyCombo.DataSource = loTable

You can obviously adjust the columns to the types and names that you want.  One other thing will be how you bind. By default, a StrataFrame combo looks at the Selectedvalue property for binding.  You can also adjust this by setting the BindingProperty of the combo to meet your needs.

By Keith Chisarik - 11/2/2006

So you cant just manually add the values "PA","NJ" in the "Edit Items" list and bind to a field in the BO?



MY BO has only one record and has a value in the field I am trying to bind to.
By Keith Chisarik - 11/2/2006

My DB does not allow NULL and has a default value defined via the DDT.
By Trent L. Taylor - 11/2/2006

Yes, but you'll have to change the BindingProperty to Text instead Selected Value.
By Trent L. Taylor - 11/2/2006

My DB does not allow NULL and has a default value defined via the DDT.

This doesn't have anything to do with it...you are not dealing with the DDT or the default values at this point....your problem is that the combo box is expecting the SelectedValue property to be set as it is the default property used for binding.  Change the BindingProperty to Text.

By Keith Chisarik - 11/2/2006

you sir, are the MAN!



it works Smile