PDA

Click to See Complete Forum and Search --> : combbox


Palmtree
Nov 12th, 2002, 03:48 PM
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

DBridle
Nov 12th, 2002, 03:52 PM
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.

Palmtree
Nov 12th, 2002, 03:58 PM
Thanks for the reply.
I tried that , not work neither.

Edneeis
Nov 12th, 2002, 04:36 PM
So what is the problem? Are you getting an error? If so which one?

Edneeis
Nov 12th, 2002, 04:36 PM
Ahh nevermind I just spotted webform. Set the AutoPostBack on the combo to True.

hellswraith
Nov 12th, 2002, 10:08 PM
Or instead of this:
Label5.Text = combProduct.SelectedIndex
do this:
Label5.Text = combProduct.Text

Edneeis
Nov 12th, 2002, 11:31 PM
But still if the postback is not set then the event doesn't fire until the next time the page is loaded.