DropDownList DataTextField with Multiple Columns

In actual the ASP.Net DropDownList control does not support multiple column names for its DataTextField property that provides the functionality to map the field of database table whose value appear as text in the dropdownlist menu. If you want to display the values retrieved from the multiple columns of database table then you cannot specify the names of multiple columns to the DataTextField property instead you have to build your own logic to provide the functionality.

 

In this sample we have used the Employees table of Northwind SQL database to show you the possible output that can be generated for displaying the multiple column values as text value of list item of dropdownlist control. We have used the SqlDataReader object to read the forward-only stream of SQL records to add the ListItems dynamically by specifying the combined string type value to display the FirstName and LastName of each employee as a list item of dropdownlist control. You can also modify the SQL query by concatenating the values of multiple fields and assigning a single alias for the new customized field that can be specified as a value for DataTextField property of dropdownlist control to display the text items.

 

See the sample below to understand the functionality of displaying the values of multiple columns as text value of list items of ASP.Net DropDownList control:

Select any list item
  1. Adrotator Control Using XML File
  2. CheckBox Control Sample
  3. FileUpload File Type Filter using JavaScript
  4. LinkButton Control Click Event
  5. RadioButton Control Sample
  6. RadioButton Control Checked and GroupName Property
  7. LinkButton Control Command Event
  8. HiddenField Control
  9. CheckBox Checked Property
  10. Adrotator Control using SqlDataSource
  11. BulletedList Control
  12. CheckBox AutoPostBack Property
  13. HiddenField Control OnValueChanged Event
  14. LinkButton OnClientClick Property
  15. RadioButton Control AutoPostBack Property
  16. RadioButton Control OnCheckedChanged Event
  17. LinkButton JavaScript Confirm Message Box
  18. HyperLink Control Sample
  19. CheckBox OnCheckedChanged Event
  20. BulletedList Control using DisplayMode
  21. BulletedList Control using SqlDataSource
  22. CheckBox Control JavaScript Validation
  23. HyperLink Control NavigateUrl Property
  24. LinkButton JavaScript Alert Box
  25. RadioButtonList Control Sample
  26. RadioButtonList Control Layout Properties
  27. LinkButton PostBackUrl Property
  28. HyperLink Control Target Property
  29. CheckBox Control Select All Using PostBack in C#
  30. BulletedList Control with Click Event
  31. Button Control
  32. CheckBox Control Check All Using JavaScript
  33. HyperLink Control ImageUrl Property
  34. Multiple LinkButtons Single Command Event Handler
  35. RadioButtonList Control OnSelectedIndexChanged Event
  36. RadioButtonList Control with SQL DataBinding
  37. ListBox Control Sample
  38. HyperLink Control OnClick Event
  39. CheckBoxList Control Sample
  40. Button Click Event
  41. Button Command Event
  42. CheckBoxList Control Layout Properties
  43. HyperLink Control Open in New Window
  44. ListBox Control AutoPostBack Property
  45. Populate RadioButtonList Control Items Dynamically
  46. TextBox Control Text Property
  47. ListBox Control OnSelectedIndexChanged Event
  48. Image Control Sample
  49. CheckBoxList Control OnSelectedIndexChanged Event
  50. Button OnClientClick Property
  51. Button Confirm Message Box
  52. CheckBoxList Control with SQL DataBinding
  53. Image Control ImageAlign Property
  54. ListBox Control SelectionMode Property
  55. TextBox Control TextMode Property
  56. TextBox Control OnTextChanged Event
  57. ListBox Control with SQL DataBinding
  58. ImageButton Control Sample
  59. CheckBoxList Control Selected Items
  60. Button Alert Message Box
  61. Button UseSubmitBehavior Property
  62. Populate CheckBoxList Control Items Dynamically
  63. ImageButton OnClick Event
  64. ListBox Control Get Multiple Selected Items
  65. XML Control with DocumentSource and TransformSource Property
  66. Populate ListBox Items Dynamically
  67. ImageButton OnCommand Event
  68. CheckBoxList Control JavaScript Validation
  69. Button PostBackUrl Property
  70. Multiple Button Controls with Single Event Handler
  71. CheckBoxList Control Select All Using PostBack in C#
  72. ImageButton OnClientClick Property
  73. ListBox Control SelectedValue Property
  74. ListBox Control SelectedIndex Property
  75. ImageButton PostBackUrl Property
  76. CheckBoxList Control Select All Using JavaScript
  77. Calendar Control
  78. Calendar Control SelectionMode Property
  79. DropDownList Control Sample
  80. Determine the Image Coordinates Using ImageButton Control
  81. Literal Control
  82. Literal Control Mode Property
  83. ImageMap Control
  84. DropDownList Control AutoPostBack Property
  85. Calendar Control SelectionChanged Event
  86. Calendar Control VisibleMonthChanged Event
  87. DropDownList Control OnSelectedIndexChanged Event
  88. ImageMap HotSpotMode Property
  89. Panel Control
  90. PlaceHolder Control
  91. ImageMap Click Event
  92. DropDownList Control with SQL DataBinding
  93. Calendar Control DayRender Event
  94. Calendar Control Date with Custom Content
  95. Populate DropDownList Items Dynamically
  96. ImageMap PostBackValue Property
  97. Label Control Text Property
  98. Setting DropDownList Default Value
  99. Calendar Control SelectedDates Dynamically
  100. Calendar Control SelectedDates using SQL Database
  101. DropDownList Control SelectedValue Property
  102. Label Control As Caption
  103. DropDownList Control SelectedIndex Property
  104. Calendar Control in Popup Window
  105. Calendar Control Customized with CSS Styles
  106. DropDownList Control JavaScript Validation
  107. DropDownList DataTextField with Multiple Columns
  108. Calendar DatePicker Control
  109. DropDownList Control with XML DataBinding