Click to See Complete Forum and Search --> : dropdownlist returning selectedvalue when trying to get text
JoeyD
04-01-2006, 05:53 AM
I am trying to get the text out of a dropdownlist (JobLine). The text is someting like "HV20" AND the selectedValue would be 18. When I write the statement below the s.electedvalue returns 18 but the .Text also return 18 instead of the HV20 I am looking for. I tried this in VB and got the same results, I move the comboboxes select statement from a procedure to a selection string, and I took out my where clauses to see if I was producing anything buggy there. The dropdownlist displays the proper text in the list also. Anyhelp would be greatly appreciated
this.TextBox4.Text = this.JobLine.Selectedvalue + " " + this.JobLine.Text; :mad:
sirpelidor
04-02-2006, 06:22 PM
hi, how did you generate your dropdownlist?
for example, if I wanna create a drop down list (ddlst) for gender (Male/Female) with the value M for Male, and F for Female.
//text shows at the control
ddlst.items.Add("Female");
ddlist.items.Add("Male");
//value off the drop down list
ddlist.Items[0].Value = "F"
ddlist.Items[1].Value = "M"
now when I wanna get the word Male, I do:
string gender = ddlist.SelectedItem.toString();
if I wanna get the gender code instead of the word, I do:
string genderCode = ddlist.SelectedValue.toString();
if you don't tell your control what the value is, it will default the value to the item text.
handshakeit
04-03-2006, 03:16 AM
I think u got the solution by sirpelidor
Try this
this.TextBox4.Text = this.JobLine.SelectedItem.toString();