Solved

combo box databinding problem

Posted on 2006-07-20
2
219 Views
Last Modified: 2010-04-23
Hi, everybody,

I have a winform combo box that binds to a dataset created by a sql stored proc. My question is how to make the combo box default to an empty/null value?

The combo is for users to select a Region as searching criteria. It has to be optional, meaning, it has to contain an empty entry with the regular West, East...

Do I make my stored proc returns an empty line at the top of normal data set, or add an empty entry into combo box after it was populated?

Neither seems is the right way to handle the situation.

Thanks!
0
Comment
Question by:ommer
2 Comments
 
LVL 17

Accepted Solution

by:
ZeonFlash earned 125 total points
ID: 17149883
Either way is acceptable.  

SELECT NULL, NULL
UNION
SELECT Region, RegionValue
FROM ...

--Or--

'Fill dataset

Dim dr As DataRow = ds.Tables(0).NewRow

For Each col As DataColumn In ds.Tables(0).Columns
      dr.Item(col) = DBNull.Value
Next

ds.Tables(0).Rows.InsertAt(dr, 0)

'Bind dataset to combobox here
0
 

Author Comment

by:ommer
ID: 17153837
Cool!
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Exit the loop 4 49
VB.net Facial recognition software (time and attendance) 6 60
ASP/VB email question 4 46
Need syntax help building hyperlink 2 20
Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used.

791 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