-
combbox
hi,
I have a label and a combbox on my web form.
what I want to do is after I change the comb's selection, the lable displays the comb's SelectedIndex. It is so simple, but I just can not make it work. Can somebody help? thanks.
The following is my code:
Private Sub combProduct_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles combProduct.SelectedIndexChanged
Label5.Text = combProduct.SelectedIndex
End Sub
-
if its throwing you an error, you probably need..
label5.text = combproduct.selectedindex.tostring
you should probably put .tostring there anyway seeing as your going from an int to a string.
-
Thanks for the reply.
I tried that , not work neither.
-
So what is the problem? Are you getting an error? If so which one?
-
Ahh nevermind I just spotted webform. Set the AutoPostBack on the combo to True.
-
Or instead of this:
Label5.Text = combProduct.SelectedIndex
do this:
Label5.Text = combProduct.Text
-
But still if the postback is not set then the event doesn't fire until the next time the page is loaded.