PC Review


Reply
Thread Tools Rate Thread

Databinding With Objects

 
 
Patrick
Guest
Posts: n/a
 
      14th Feb 2007
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


 
Reply With Quote
 
 
 
 
aaron.kempf@gmail.com
Guest
Posts: n/a
 
      14th Feb 2007
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.com> wrote:
> 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



 
Reply With Quote
 
RobinS
Guest
Posts: n/a
 
      14th Feb 2007

"Patrick" <(E-Mail Removed)> wrote in message
news:uhNokQ%(E-Mail Removed)...
> 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.


 
Reply With Quote
 
pfc_sadr@hotmail.com
Guest
Posts: n/a
 
      14th Feb 2007
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.none> wrote:
> "Patrick" <Patr...@home.com> wrote in message
>
> news:uhNokQ%(E-Mail Removed)...
>
>
>
>
>
> > 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 -



 
Reply With Quote
 
Patrick
Guest
Posts: n/a
 
      15th Feb 2007
Thanks Robin, that was very helpful and exactly what I was looking for.
Thanks again.
Patrick

"Patrick" <(E-Mail Removed)> wrote in message
news:uhNokQ%(E-Mail Removed)...
> 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
>



 
Reply With Quote
 
RobinS
Guest
Posts: n/a
 
      15th Feb 2007
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Thanks Robin, that was very helpful and exactly what I was looking for.
> Thanks again.
> Patrick
>
> "Patrick" <(E-Mail Removed)> wrote in message
> news:uhNokQ%(E-Mail Removed)...
>> 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
>>

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Databinding expressions are only supported on objects that have a DataBinding event jobs Microsoft ASP .NET 0 26th Sep 2007 12:54 AM
databinding and objects tarscher@gmail.com Microsoft ASP .NET 0 11th Oct 2006 04:44 PM
DataBinding objects in the Designer/GUI dev@fwcjua.com Microsoft C# .NET 1 26th Jul 2006 10:06 AM
Databinding: Objects within Objects as Properties Aaron Moore via .NET 247 Microsoft Dot NET Framework Forms 0 10th Jun 2004 03:48 PM
DataBinding with Custom Objects Steve Microsoft Dot NET Framework 0 22nd Jul 2003 08:52 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:07 PM.