PC Review

Thread Tools Rate Thread

C# 2.0 DataBinding using the BindingSource in user controls

Posts: n/a
      27th Oct 2006

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.


Reply With Quote

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 combobox to a bindingsource - value of '0' is not valid for 'selectedindex' BillE Microsoft VB .NET 0 24th Aug 2009 06:40 PM
EDM databinding using BindingSource? Edward Microsoft ADO .NET 1 25th Sep 2008 04:41 PM
DtaGridView - Add DataBinding using bindingsource Ryan Microsoft Dot NET Framework Forms 1 15th May 2008 01:37 PM
Databinding and Bindingsource issue Newish Microsoft Dot NET Framework Forms 0 15th Oct 2006 02:04 PM
Databinding: "BindingSource - field" syntax Marc Vangrieken Microsoft Dot NET Framework Forms 2 11th Aug 2006 10:43 AM




All times are GMT +1. The time now is 09:40 AM.