Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > .NET > Other .NET > ADO.NET
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
ADO.NET For discussion about ADO.NET.††Topics such as question regarding the System.Data namespace are appropriate.††Questions specific to a particular application should be posted in a forum specific to the application .
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ADO.NET section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old November 9th, 2004, 12:02 PM
Authorized User
 
Join Date: Oct 2004
Location: , , Israel.
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
Default DataBind/DataSource problem

I have this Code:

myConnection.Open()
CommandText = "SELECT * FROM Students ORDER BY Students.firsName"
myCommand = New SqlCommand(CommandText, myConnection)

chooseStudent.DataSource = myCommand.ExecuteReader(CommandBehavior.CloseConne ction)

'Here is the problem
chooseStudent.DataTextField = "firsName" + "|" + "familyName"

chooseStudent.DataValueField = "firsName"

chooseStudent.DataBind()


In this code "chooseStudent" is a DropDownList which contain all students name.

I want that the value of each option (ListItem) will be the first name, But I want that the text will be "firstName" + "|" + "familyName".
(Like "Brad|Pit", "Gorge|Bush" and so......)

How to do it???

Reply With Quote
  #2 (permalink)  
Old November 9th, 2004, 11:19 PM
Friend of Wrox
 
Join Date: Feb 2004
Location: Bangalore, Karnataka, India.
Posts: 177
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Change the select query as follows

select Students.FirstName+'|'+familyName as FullName Students ORDER BY Students.firsName;

then at the DataTextField property set as follows

chooseStudent.DataTextField = "FullName"



It is not how much we do,
but how much love we put in the doing.

-Mother Theresa
Reply With Quote
  #3 (permalink)  
Old November 10th, 2004, 05:01 AM
Authorized User
 
Join Date: Oct 2004
Location: , , Israel.
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
Default

But I want that:

chooseStudent.DataValueField = "firsName"

also


How to do booth???

Reply With Quote
  #4 (permalink)  
Old November 10th, 2004, 08:15 AM
planoie's Avatar
Friend of Wrox
Points: 16,481, Level: 55
Points: 16,481, Level: 55 Points: 16,481, Level: 55 Points: 16,481, Level: 55
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

SELECT firsName+'|'+familyName as FullName, firsName FROM Students ORDER BY firsName;

chooseStudent.DataTextField = "FullName"
chooseStudent.DataValueField = "firsName"
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Object datasource VS DataSource SoftMind BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 4 July 27th, 2006 10:44 PM
DataBind Problem liorlankri ADO.NET 3 November 2nd, 2004 03:13 PM
MSHFlexGrid with DataSource Problem samryan VB Databases Basics 1 September 10th, 2004 08:06 AM
problem to deploye extended datasource Choose File BOOK: Professional SQL Server Reporting Services ISBN: 0-7645-6878-7 0 July 16th, 2004 10:46 AM
Problem reading DataReader after Databind rathbird ADO.NET 1 March 10th, 2004 04:53 PM



All times are GMT -4. The time now is 10:27 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.