1

I have two combobox..and i have a add button..if both combobox having value then only

i want to add my combobox item to grid view ..so i given validation like this:

 If (cmbside.Text = " " And cmbDamage.Text = " ") Then
            MsgBox("Please Select Both Item", MessageBoxIcon.Information)
        End If

so this case if if i keep one combobox value blank ,
,then also another value is adding to grid view.

what is wrong with my code

0

2 Answers 2

1

Maybe it's about " " ...

If cmbside.Text = "" And cmbDamage.Text = "" Then
    MsgBox("Please Select Both Item", MessageBoxIcon.Information)
End If

or

If cmbside.SelectedIndex = -1 And cmbDamage.SelectedIndex = -1 Then
    MsgBox("Please Select Both Item", MessageBoxIcon.Information)
End If
Sign up to request clarification or add additional context in comments.

Comments

0

If you want to add both combobox value in gridview check the condition like this

 If ComboBox1.Text.Trim = String.Empty OrElse ComboBox2.Text.Trim = String.Empty Then
            MsgBox("Please Select Both Item", MessageBoxIcon.Information)
        End If

2 Comments

It doesn't really matter in this case, but you should really use OrElse instead of Or.
ok,,sir,,thanks,,this got worked fine for me..thanks for your help

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.