?
Solved

Null values in bound combobox

Posted on 2006-06-13
7
Medium Priority
?
348 Views
Last Modified: 2008-03-10
I use a combobox to edit the field "ReutersChains" in the table "Instruments".
This is a numeric field, the corresponding strings are stored in the table "ReutersChains".

Simple binding to instruments.ReutersChains. (uses selectedValue)
Complex binding to ReutersChains.Id and name.

This works perfectly.

Now what would be a good (the best?) way to enable clearing the field?

Option1:
Add a NONE record with id 0 to the table ReutersChains.

Option2:
If I clear the text of the combo, somehow I place null or 0 in the field ReutersChains.
This would involve some figuring out how to program this.
As far as I know the binding to selectedValue doesn't support such a thing, right?

Other ideas?
0
Comment
Question by:NicoLaan
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
7 Comments
 
LVL 9

Accepted Solution

by:
lojk earned 1000 total points
ID: 16898107
ACtually the convention is to add (none)
including the brackets, to ensure is top of the list. This approach has some major bonuses later when you come to join the two tables because you dont need to add specific casting and formatting for null values when outputting. Of course once you adopt this standard it makes sense to apply it for all similar lookup table combos..

in an unbound (dropdownlist ) combo you can normally set the selected index to -1, which would clear the combo selection but according to the msdn you cant do this on a databound.. Is there no way you can just use an unbound combo and handle the loading and evaluating as required?
0
 
LVL 4

Author Comment

by:NicoLaan
ID: 16900933
You're right about that, using the (none) value would be the most common method I think.
The problem is software using the current data would have to be changed. Now it will find a (none) (null) link with the reauterschains table. However changing this code would be easy and make it work more properly I feel.

If I'd use option 2 and do some clearing of the combo, doing it unbound would be an idea but really seems more messy.
0
 
LVL 9

Expert Comment

by:lojk
ID: 16900972
update reuterschain set ID=0 where id=null... odds are youll probably end up removing code rather than adding it to implement this change in the app.

Nulls are often more trouble than they are worth.. if you can include a known 'null' value (i.e. zero) it is always simpler when creating reports, loading combos et.al

Of course the question is did you not consider these problems during your design phase? (*Excessively Loud Coughing and mumbling*) Perhaps next time, eh?

;-)
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 4

Author Comment

by:NicoLaan
ID: 16906959
My boss designed the start of it, I'm just cleaning up his mess. ;-)
Well, honestly he did a good job most of the time but consistency slip ups like these I do occasionally find and then we discuss, redesign this part or that part.
Also caused because it's a big work in progress, new insights partially changing database and software design.
I think I would have designed it the proper way with (none), so I could have made some other slip ups.
0
 
LVL 9

Expert Comment

by:lojk
ID: 16907024
Theres always *one more* slip up to make...

0
 
LVL 4

Author Comment

by:NicoLaan
ID: 17075359
Ouch, sorry, I completely forgot to rate it.
Sorry about that, thanks lojk for your thinking and TheLearnedOne for your reminder.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question