How to capture the DataTextField Value?


Dear Experts,
   
In VS 2005, I have a DropDownList having DataTextField="FullName" and DataValueField="ApprovedBy".

To get the DataValueFiled Value = this.ApprovedBy.SelectedValue. Although the display is readable as "Jaime Jegonia", how can I capture that Fullname "Jaime Jegonia" so I can use it for whatever  purpose in the program?

Thanks,


Jimi J
   
This is the ASPX tag:
        <asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True" DataSourceID="SqlDataSource2"
            DataTextField="FullName" DataValueField="ApprovedBy">
        </asp:DropDownList>
JaimeJegoniaAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

e1vCommented:

DropDownList1.SelectedItem.Text
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
JaimeJegoniaAuthor Commented:


DropDownList1.SelectedItem.Text  is always = DropDownList1.SelectedValue
0
JaimeJegoniaAuthor Commented:
elv,

Sorry, you are right. I just tried it's OK. Before I was using interchangeably SelectedItem.Text  & SelectedValue, I always get the same result. Can you explain to me why?


Thanks,


Jimi J
0
Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

JaimeJegoniaAuthor Commented:
How can I fill or bind the DropDownList with Datareader so that  I can always both the Text and Value?

if I use DropdownList.Items.Add(index, ListItem) - I can only get either TextField or ValueField.


Thanks,

Jimi J
0
e1vCommented:
You can use DropDownList.Items.Add(new ListItem("text", "value")) or  DropDownList.Items.Insert(index, new ListItem("text", "value"))  to add a listitem with value and text.

if you use Items.Add("string") the value and text will be the same.
0
JaimeJegoniaAuthor Commented:
elv,

I got it. Thank you very much!

Jimi J
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C#

From novice to tech pro — start learning today.

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.