Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
|
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 2nd, 2007, 11:55 AM
Authorized User
 
Join Date: Sep 2007
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
Default Dropdown list question

Hi everyone,
I have a question. I am filling a dropdownlist with the first and lastname of my table employees. The problem is that I want to get the employee's id but I don't want it to be displayed in my dropdownlist. I don't know if there is any chance to put set the employee_id as the value of each <asp:ListItem></asp:ListItem> and then get it by using the SelectedValue property?

Thanks!

pd. I am using a DataSource to fill my dropdownlist and a stored procedure that selects only first and lastname from my tableEmployee.
 
Old October 2nd, 2007, 12:14 PM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

Can't you change the store procedure to bring back the extra column, then you can bind the DataValueField to the id and DataTextField to the full name?

--

Joe (Microsoft MVP - XML)
 
Old October 2nd, 2007, 12:17 PM
Authorized User
 
Join Date: Sep 2007
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Yes, and thank you but I don't exactly know how to bind a DataValueField with my column employee id
 
Old October 2nd, 2007, 12:34 PM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

Code:
ddlMyList.DataValueField = "EmployeeId";
or in markup as an attribute:
Code:
DataValueField="EmployeeId";[/
--

Joe (Microsoft MVP - XML)
 
Old October 2nd, 2007, 02:48 PM
Authorized User
 
Join Date: Sep 2007
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank you and one last question. Can 2 columns be displayed in a single DataTextField? It only accepts me one column value...





Similar Threads
Thread Thread Starter Forum Replies Last Post
Two Level Dynamic DropDown List Error Question workib BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 1 May 3rd, 2008 02:37 AM
fill dropdown list with items when parent list isaac_cm Pro PHP 1 July 10th, 2006 05:41 AM
Dropdown list question NeoDelphi C# 3 December 25th, 2004 12:46 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.