tags:

views:

32

answers:

1

Hi Guys,

I am working on a windows application. I just wanted to generalize the code for all the master forms. So I decided to create a user control with specific containers. We are using LINQ to SQL and I wanted to pass on a table name and get the corresponding data. I have a BindingSource and a BindingNavigator along with a DataGridView. I use the following code:

Dim t As Type = objDB.GetType()

Dim p As PropertyInfo = t.GetProperty(value)

Dim table = CType(p.GetValue(objDB, Nothing), ITable)

dgvMaster.DataSource = table 'attaching the table as datasource to datagrid works

BSMaster.DataSource = table 'trying to attach the datasource to binding source fails

All it takes is to figure out how to bind it to binding source and I am done. Any ideas or help in this regard is much appreciated.

Thanks,

Raja

A: 

Please check the BSMaster.Count value after it being populated.
The problem seems to be associated with DataGridView display.
The scenario may be caused by empty initial column set in DataGridVIew
(common reason is the fact that DataSource was not assigned in design time).

Devart
The problem is that BS Master does not get any data when I assign the ITable. It really works well if I specify the exact class. For ex. objDB.Categories. Thats why I wanted to change the ITable to Table( Of Categories).
Raja
If the BSMaster does not contain any data, this behaviour is expected. BindingSource performs an attempt to create some columns from table, fails and after this does not make any other attempt to recreate columns. You can either create the columns manually or pass a type for columns to be created.
Devart