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?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Similar Threads
  1. Guest

    Controls not refreshed using object databinding

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

    DataBinding with controls on a tabpage

    Guest, Feb 23, 2004, in forum: Microsoft Dot NET Framework Forms
    Replies:
    5
    Views:
    2,237
    Guest
    Mar 1, 2004
  3. Clive Dixon
    Replies:
    0
    Views:
    990
    Clive Dixon
    May 26, 2004
  4. Guest

    Adding Record Using BindingSource and BindingNavigator

    Guest, Jun 15, 2006, in forum: Microsoft Dot NET Framework Forms
    Replies:
    0
    Views:
    890
    Guest
    Jun 15, 2006
  5. Marc Vangrieken

    Databinding: "BindingSource - field" syntax

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

    Databinding and Bindingsource issue

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

    DtaGridView - Add DataBinding using bindingsource

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

    bindingsource - find all bound controls

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