473,402 Members | 2,055 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,402 software developers and data experts.

Databinding With Objects

I've been struggling with a while. Could someone please help me out?
I need to bind a property (wich is an custom object)
to a combobox that contains a list of the same objects.

ex:
class Manager()
{
public Employee EmployeeInfo
}

combobox contains a collection of Employee objects.
When navigating, I would like to autimatically display a field from the
corresponding Employee object from the combo that matches what is assigned
to the Manager. As well as be able to change the Managers Employee object to
what is selected in the combobox.

Everything works fine when I change the Employee object of the Manager to
say... EmployeeID (Which is a string).

Thanks a whole million!
--PAtrick
Feb 14 '07 #1
5 1738
C# does not support databases; they shoved XML and OOP so far down our
throats; I haven't made it to databases yet.. It's like databases are
an afterthough for C#

(NO WONDER ORACLE IS CLEANING MICROSOFTS CLOCK)

On Feb 13, 6:59 pm, "Patrick" <Patr...@home.comwrote:
I've been struggling with a while. Could someone please help me out?
I need to bind a property (wich is an custom object)
to a combobox that contains a list of the same objects.

ex:
class Manager()
{
public Employee EmployeeInfo

}

combobox contains a collection of Employee objects.
When navigating, I would like to autimatically display a field from the
corresponding Employee object from the combo that matches what is assigned
to the Manager. As well as be able to change the Managers Employee object to
what is selected in the combobox.

Everything works fine when I change the Employee object of the Manager to
say... EmployeeID (Which is a string).

Thanks a whole million!
--PAtrick

Feb 14 '07 #2

"Patrick" <Pa*****@home.comwrote in message
news:uh****************@TK2MSFTNGP02.phx.gbl...
I've been struggling with a while. Could someone please help me out?
I need to bind a property (wich is an custom object)
to a combobox that contains a list of the same objects.

ex:
class Manager()
{
public Employee EmployeeInfo
}

combobox contains a collection of Employee objects.
When navigating, I would like to autimatically display a field from the
corresponding Employee object from the combo that matches what is
assigned to the Manager. As well as be able to change the Managers
Employee object to what is selected in the combobox.

Everything works fine when I change the Employee object of the Manager to
say... EmployeeID (Which is a string).

Thanks a whole million!
--PAtrick
Are you saying this: you are navigating through a list of Managers. Manager
has a property called Employee. Somewhere else there is a list of
Employees.

You want to bind the combobox so it saves the EmployeeID in the Manager
object, but shows the entries from the Employee list as options to be
selected?

You want to bind the combobox to the Employee list, then bind the
SelectedValue to the EmployeeID in the Manager object.

myComboBox.DataSource = EmployeeList
myComboBox.DisplayMember = EmployeeList.EmployeeName
myComboBox.ValueMember = EmployeeList.EmployeeID
myComboBox.SelectedValue = ManagerList.EmployeeID

Oh, and ignore that post from AaronKempf; he's trolling.

Good luck, and if I didn't get the gist of your problem, please post again.

Robin S.
Ts'i mahnu uterna ot twan ot geifur hingts uto.
Feb 14 '07 #3
if you want to just bind, set the recordsource of your form and your
controlsource on the control

OH, WAIT A SECOND, CSHARP DOES NOT KNOW ANYTHING ABOUT DATABASES

On Feb 14, 12:30 am, "RobinS" <Rob...@NoSpam.yah.nonewrote:
"Patrick" <Patr...@home.comwrote in message

news:uh****************@TK2MSFTNGP02.phx.gbl...


I've been struggling with a while. Could someone please help me out?
I need to bind a property (wich is an custom object)
to a combobox that contains a list of the same objects.
ex:
class Manager()
{
public Employee EmployeeInfo
}
combobox contains a collection of Employee objects.
When navigating, I would like to autimatically display a field from the
corresponding Employee object from the combo that matches what is
assigned to the Manager. As well as be able to change the Managers
Employee object to what is selected in the combobox.
Everything works fine when I change the Employee object of the Manager to
say... EmployeeID (Which is a string).
Thanks a whole million!
--PAtrick

Are you saying this: you are navigating through a list of Managers. Manager
has a property called Employee. Somewhere else there is a list of
Employees.

You want to bind the combobox so it saves the EmployeeID in the Manager
object, but shows the entries from the Employee list as options to be
selected?

You want to bind the combobox to the Employee list, then bind the
SelectedValue to the EmployeeID in the Manager object.

myComboBox.DataSource = EmployeeList
myComboBox.DisplayMember = EmployeeList.EmployeeName
myComboBox.ValueMember = EmployeeList.EmployeeID
myComboBox.SelectedValue = ManagerList.EmployeeID

Oh, and ignore that post from AaronKempf; he's trolling.

Good luck, and if I didn't get the gist of your problem, please post again.

Robin S.
Ts'i mahnu uterna ot twan ot geifur hingts uto.- Hide quoted text -

- Show quoted text -

Feb 14 '07 #4
Thanks Robin, that was very helpful and exactly what I was looking for.
Thanks again.
Patrick

"Patrick" <Pa*****@home.comwrote in message
news:uh****************@TK2MSFTNGP02.phx.gbl...
I've been struggling with a while. Could someone please help me out?
I need to bind a property (wich is an custom object)
to a combobox that contains a list of the same objects.

ex:
class Manager()
{
public Employee EmployeeInfo
}

combobox contains a collection of Employee objects.
When navigating, I would like to autimatically display a field from the
corresponding Employee object from the combo that matches what is
assigned to the Manager. As well as be able to change the Managers
Employee object to what is selected in the combobox.

Everything works fine when I change the Employee object of the Manager to
say... EmployeeID (Which is a string).

Thanks a whole million!
--PAtrick

Feb 15 '07 #5
You're welcome. By the way, there's a new book out called "Doing Objects in
VB2005" by Deborah Kurata that has a decent example of writing an
application using the 3-layer model. I know it's in VB, but that's not too
far from C#. She shows how to do data binding in the Designer with business
objects. Pretty cool. Just FYI.

Robin S.
-------------------------
"Patrick" <Pa*****@home.comwrote in message
news:em**************@TK2MSFTNGP05.phx.gbl...
Thanks Robin, that was very helpful and exactly what I was looking for.
Thanks again.
Patrick

"Patrick" <Pa*****@home.comwrote in message
news:uh****************@TK2MSFTNGP02.phx.gbl...
>I've been struggling with a while. Could someone please help me out?
I need to bind a property (wich is an custom object)
to a combobox that contains a list of the same objects.

ex:
class Manager()
{
public Employee EmployeeInfo
}

combobox contains a collection of Employee objects.
When navigating, I would like to autimatically display a field from the
corresponding Employee object from the combo that matches what is
assigned to the Manager. As well as be able to change the Managers
Employee object to what is selected in the combobox.

Everything works fine when I change the Employee object of the Manager
to say... EmployeeID (Which is a string).

Thanks a whole million!
--PAtrick


Feb 15 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Victor Jones | last post by:
I have a general question about the approach towards databinding controls with objects. Apart from the databinding offered by .NET to bind data, it can be extended to have the same behavior with...
0
by: Victor Jones | last post by:
I have a general question about the approach towards databinding controls with objects. Apart from the databinding offered by .NET to bind data, it can be extended to have the same behavior with...
15
by: Tim Jarvis | last post by:
Hi, I have an object that I am binding to a text box, this object exposes a boolean field, and I have implemented a format event handler and a parse event handler for the binding object, where I...
3
by: John Bailey | last post by:
When I first built a few web pages in ASP .Net 2.0, I thought it was great. The formview and detailview contorls would automatically layout the controls for you, the update methods were...
1
by: Solitus | last post by:
I have databinding problem with a repeater <ItemTemplate> <tr> <!-- fixed content --> </tr> <tr> <!-- optional content --> </tr> </ItemTemplate>
5
by: Trail Monster | last post by:
Ok, I've been searching the net now for several days and can't find how to do this anywhere. Version: VS 2005 Professional Release, 2.0 Framework Background: I have a complex business object...
0
by: dba123 | last post by:
In my GridView I have this: <Columns> <asp:TemplateField HeaderText="Title" SortExpression='<%#((Podcast)Container.DataItem).Title %>'> <ItemTemplate> <asp:Image ID="Image1"...
8
by: Dirk | last post by:
Hello, I have a problem to use databinding with my business layer classes. My data class does not have simple properties (string, int or datetime), instead, all my properties are objects of the...
2
by: udupi_mail | last post by:
Hello, Was hoping to get some feeback on the following: Current arch. is a swing client with corba services deployed on AIX. Data tranferred over the wire is XML(string) instead of traditional...
1
by: =?Utf-8?B?QWxoYW1icmEgRWlkb3MgS2lxdWVuZXQ=?= | last post by:
Hello to all, I want to know if DataBinding in asp.net 2,0 is better than to fill up the values of the controls of the following form: this.miControlTextBox.Text = valorParaControlTextbox; ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.