Need help

madi2999

Member
Joined
Aug 8, 2004
Messages
10
Programming Experience
Beginner
I have few dropdown lists on my application and I want when the user chooses any option from anyone of the lists; for the options chosen to be displayed on a label as on string. ( year_process_format)



My problem is that when a user chooses from the first list the chosen option is displayed but upon choosing the second one it overwrites the first one.



I have tried this

Year=dropdwonlist 1. selecteditem.tostring

lblfilename.text=lnlfilename.txt & Year



this works fine but the problem is that when the user goes back to one of the list that he had chosen an option from earlier, the chosen option gets appended to the string displayed on the label as oppose for it to overwrite it designated space within the string

I am trying to do the above using asp.net


Your help is highly appreciated

 

talentrio

Member
Joined
Sep 15, 2004
Messages
7
Programming Experience
10+
Simple fix

Just create a function called buildstring or something and call it in each dropdownlists SelectedIndexChanged() function

Here is vb.net source code:
...


PrivateSub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) HandlesMyBase.Load
'populate dropdownlist boxes

Dim i As Int32
For i = 1900 To 2004

DropDownList1.Items.Add(i.ToString)

Next

DropDownList1.Text = "Please Select Year"



For i = 1 To 12

DropDownList2.Items.Add(i.ToString)

Next

DropDownList2.Text = "Please Select Month"



For i = 1 To 28

DropDownList3.Items.Add(i.ToString)

Next

DropDownList3.Text = "Please Select Day"

EndSub

PrivateSub DropDownList1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DropDownList1.SelectedIndexChanged

BuildString()

EndSub

PrivateSub DropDownList2_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DropDownList2.SelectedIndexChanged

BuildString()

EndSub

PrivateSub DropDownList3_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DropDownList3.SelectedIndexChanged

BuildString()

EndSub

PrivateFunction BuildString()

'update textbox1
TextBox1.Text = DropDownList2.SelectedItem & " " & DropDownList3.SelectedItem & " " & DropDownList1.SelectedItem
EndFunction



hope this helps!

 
Top Bottom