C# 2.0 DataBinding using the BindingSource in user controls

Discussion in 'Microsoft Dot NET Framework Forms' started by Rajat, Oct 27, 2006.

  1. Rajat

    Rajat Guest

    Hi,

    I have a user control B put inside the parent user control A.

    On the child control B, I have put a combo box and a BindingSource BS1. In
    the load event of child control B, I fetch the
    values from the database and put in a generic BindingList of NameValueClass.
    (given below)


    class NameValueClass
    {

    private int _id;
    public int Id
    {
    get{return _id;}
    set{_id = value;}
    }


    private string _name;
    public int Id
    {
    get{return _name;}
    set{_name = value;}
    }

    }

    BindingList<NameValueClass> list = RetrieveComboValuesFromDataBase();

    Next I assign the list to datasource of BindingSource BS1 (given below)


    BS1.DataSource = list;

    combo.DataSource = BS1;
    combo.DataMember = "Name";
    combo.ValueMember = "Id" ;

    I have put a Grid on Parent control A. Now I want to show some detail data
    on grid, On changing the combo box value i.e. As soon as the
    value in the combo box is changed, I need to fetch corresponding details
    from database and display on grid. What is the best
    way to achieve the same using the BindingSource.

    Regards,
    Rajat.
     
    Rajat, Oct 27, 2006
    #1
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Guest

    Controls not refreshed using object databinding

    Guest, Feb 8, 2004, in forum: Microsoft Dot NET Framework Forms
    Replies:
    0
    Views:
    143
    Guest
    Feb 8, 2004
  2. Marc Vangrieken

    Databinding: "BindingSource - field" syntax

    Marc Vangrieken, Aug 9, 2006, in forum: Microsoft Dot NET Framework Forms
    Replies:
    2
    Views:
    504
    Marc Vangrieken
    Aug 11, 2006
  3. Newish

    Databinding and Bindingsource issue

    Newish, Oct 15, 2006, in forum: Microsoft Dot NET Framework Forms
    Replies:
    0
    Views:
    221
    Newish
    Oct 15, 2006
  4. Ryan

    DtaGridView - Add DataBinding using bindingsource

    Ryan, May 14, 2008, in forum: Microsoft Dot NET Framework Forms
    Replies:
    1
    Views:
    288
  5. Smola

    bindingsource - find all bound controls

    Smola, Jul 11, 2009, in forum: Microsoft Dot NET Framework Forms
    Replies:
    0
    Views:
    752
    Smola
    Jul 11, 2009
Loading...

Share This Page