Stringing the DataTextField value in ASP C# Code behind?

There are occasions when I need to pass the datatextfield value along to the next page in a querey string in my ASP C# webpage.  I can't quite figure out how to do this.  I can get the datavaluefield value, but the datatextfield always just passses along the name of the column the datatextfield is drawing from in my datasource.

For example, if my datasource has two coluimns:

ItemNumber | ItemName
1                  | Candy
2                  | Hamburger

Sometimes I would want to pass the ItemNumber, and some time I want to pass the ItemName, depending on some other factors determined in the page.  I need it to work off the same single datasource and dropdownlist

  Is this even possible?
reedsster1Asked:
Who is Participating?
 
mrichmonCommented:
Usually you do something like this to get the selected value:

DropDownListId.SelectedValue

If you want the text value of the selected field then you could do:

string selectedtext = DropDownListId.Items[DropDownListId.SelectedIndex].Text;
0
 
reedsster1Author Commented:
This worked immediatly,  Thank you so much for your help.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.