Dynamic table generation through LINQ To SQL. How to change ITable to Table?
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
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).
精彩评论