CodeVerge.Net Beta


   Item Entry   Register  Login  
Microsoft News
Asp.Net Forums
IBM Software
Borland Forums
Adobe Forums
Novell Forums




Can Reply:  No Members Can Edit: No Online: Yes
Zone: > Asp.Net Forum > general_asp.net.getting_started Tags:
Item Type: Date Entered: 2/8/2007 3:36:54 PM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
NR
XPoints: N/A Replies: 1 Views: 14 Favorited: 0 Favorite
2 Items, 1 Pages 1 |< << Go >> >|
"Warenth" <>
NewsGroup User
Databinding, Access to DataSource2/8/2007 3:36:54 PM

0

I'm trying to understand databinding and am currently binding to a ComboBox, setting the DataTextField and DataValueField. How do I access properties of the datasource that aren't those two fields?

For example:
Lets say I'm creating a DropDownList of employees. Each Employee has three fields (Name, ID, Age). 
I programatically bind to this list of Employees, that is created on initial page load, setting my DataTextField equal to name, and DataValueField equal to ID.
I then later in the page, after postback, want to access the Age of the currently selected employee.

How can I do this?

Is it possible to cast my SelectedItem back to an Employee and use its properties? (I've attempted this but had no luck).

 Thanks in advance.


Think like a man of action; act like a man of thought.
"Mikesdotnettin
NewsGroup User
Re: Databinding, Access to DataSource2/8/2007 5:21:48 PM

0

The only way you can do this is to perform a lookup in the database

SELECT Age From Employees WHERE EmployeeID = @ID 

@ID is the selectedvalue 


Regards Mike

8 out of 10 questions have already been asked. Their answers can be found using Google. Go on, try it.

If you prefer code samples or tutorials in another language, translate it for free at www.codechanger.com
2 Items, 1 Pages 1 |< << Go >> >|


Free Download:













dynamic html & asp.net 2.0

how to put absolute url in sitemap?

problems with skins when dynamically loading custom controls

create webpage with sitemap data

placeholder disappears after second page...

jscript compatablity in firefox

problem with repeater and sitemap

frames and asp.net

another question about treeview

masterpage - where to open the database connection for best performance?

what's the wrong with master page and postback ?

source code for xmlsitemapprovider, staticsitemapprovider, and other providers availible for download.

trying to add tree view

cache master page

site map best practice use

usercontrols and javascript

sitemap

limit size of table cell to allow scroll bars, vwd search capabilities

problem with menu control and flash movie

problem to design menu with swap image

please help with the error: requires page.header to be non-null

changing the placement of nodes in treeview

file upload and calendar control problem on content page

'unable to cast object of type' error

menu&submenu alignment in masterpage

datasource navigator ????

callback in contentplaceholder

problems when publish a master page website.

event does not fire on treeview selection

problem with the treeview control in asp.net 2.0

finding a treenode with getelementbyid

theming parsed child controls

problems with navigation elements and ie7 (and ie6)

sitemap.currentnode == null - always!

pass a var from content page to master page

css in <head> or in theme?

theme is preventing link feed

change in master page property is not persisting to other pages

master page error

using codebehind with master page templates

menus in asp.net(vb)

skin file not being applied to controls inside datalist

missing themes functionality

masterpage images

how to place footer in master page?

visual web developer 2005 express - tabstrip

problem in programmatically change the masterpages at runtime

where is preinit event?

treeview and the navigateurl not working

ignoring elements from the master page

   
  Privacy | Contact Us
All Times Are GMT