How do I write code to check for empty drop-down list box

Hi there,
I need to verify that a value has been entered into a drop down box on my infopath form. I am brand new to infopath and c# so please excuse my ignorance.

What i have is a button that submits drop down/text box values to a sharepoint list. I have tried to use the standard 'Data Validation' on the drop down fields themselves, but the c# code executes first before the built in 'Data Validation' goes to check the value.

Basically I need an example of c# syntax in infopath that will check for a null value in the drop down boxes.
Here is some pseudocode of what im after

if (dropdown1 is empty) then
stop executing code and set focus to dropdown1
process rest of code

if anyone could provide an example that would be great.

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Clay FoxDirector of Business IntegrationCommented:
You could hide or disable the button, so that it is not clickable until the dropdown has a value.  That is typically what i do.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
cscb08Author Commented:
Hi clayfox. Cheerss for that. I have found the solution, I was able to find some example c# code that now works.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.