Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VB ASP.NET
i have a table
 
name dept area
mr.a IT s/w
mr. b IT H/w
mr.c Admin Admin
 
i am trying to data bind drop down list box
 
like
 
mr.a - it
mr. b - it
mr.c - Admin
 

 
i tried to have
 
dropdownbox.DataSource = ds
dropdownbox.DataValueField = "name"
dropdownbox.DataTextField = "name" & " - " & "dept"
dropdownbox.DataBind()
 
but it shows error
 
DataBinding: 'System.Data.DataRowView' does not contain a property with the name 'name - dept'
 
please help me
Posted 21-Jan-13 17:49pm
Comments
Nandakishorerao at 21-Jan-13 23:02pm
   
you cannot add the fields to datatextfield..better you prepare other column in your dataset with concating the "name"-"dept"..and then bind..it to dropdownlist..

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Hi,
 
In your SQL query itself you do some changes .
please check the below query
 
 
SELECT name,dept,name+' - ' +dept AS DETAILS FROM TABLE_NAME
 
AFTER write this query then bind the table like this.
 
dropdownbox.DataSource = ds
dropdownbox.DataValueField = "name"
dropdownbox.DataTextField = "DETAILS"
dropdownbox.DataBind()
 

  Permalink  

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



Advertise | Privacy | Mobile
Web01 | 2.8.1411022.1 | Last Updated 21 Jan 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100