Click here to Skip to main content
16,018,802 members
Please Sign up or sign in to vote.
1.50/5 (2 votes)
See more:
Hi friends,

I have doubt about simple thing,

so far ,i have used DataTextField and DataValueField in Dropdownlist without knowing of tat usage, why i using this while binding data from database...

ya i know am asking very simple question, but i hope you will help me for knowing this usage of DataTextField and DataValueField in Dropdownlist hereafter.


am looking forward for your valuable answer.......
Posted
Updated 26-Jul-16 1:54am

DataTextField is what the user can see.
DataValueField is what you can use for identify which one is selected from DropDownList.

For example you have people in your database. In this case the DataValueField can be the ID of the person and the DataTextField can be the name of the person in your DropDownList.

Check the follows:
DataValueField[^]
DataTextField[^]
 
Share this answer
 
v3
Hi
You can find the usage of all the properties related to Dropdownlist.

http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.dropdownlist.aspx[^]
 
Share this answer
 
C#
DataTextField is  what it will be displayed in dropdownlist and DataValueField is what value you will get on selection
 
Share this answer
 
Comments
Richard Deeming 26-Jul-16 9:15am    
This question was asked, answered, and solved THREE YEARS AGO.

Your answer adds nothing to the existing solutions.
C#
DataTextField is the one what it will be displayed in dropdownlist and DataValueField is what value you will get on selection in code that we may require to implement some bussiness logic.

Use the DataTextField and DataValueField properties to specify which field in the data source to bind to the Text and Value properties of each list item in the control, respectively. 
 
Share this answer
 
v2
Comments
Richard Deeming 26-Jul-16 9:16am    
This question was asked, answered, and solved THREE YEARS AGO.

Your answer adds nothing to the existing solutions.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900