Windows Develop Bookmark and Share   
 index > Windows Forms Data Controls and Databinding > Using a TableAdapter as a datasource
 

Using a TableAdapter as a datasource

I have a UserControl that I need to put a DataGridView into that is bound to a TableAdapter. I am using C#. When I drag the TableAdapter to the DataGridView and drop it onto the UserControl the DataGridView and the navigation strip is crated but there is no code generated to fill the DataGridView (the datasource or whatever).

In other words, when I create a form the same way I create the UserControl, there is a form load event that calls the TableAdapter.Fill generated but the UserControl's load event is not generated for the UserControl. Is this normal?
Sam Hobbs; see my SimpleSamples.Info
Simple Samples  Monday, August 10, 2009 6:21 AM
Hi Simple Samples,

Thank you for your feedback. I can reproduce the issue on my side too. Once I use that usercontrol on my form, it won't show any data in DataGridView. To resolve the issue, I added this.testTableAdapter.Fill(dsTest.test); to the usercontrol's constructor, then it can show the data correctly when form load.

I suggest you can post the issue to the Microsoft Connect, so that you can get email feedback to track it.

Sincerely,
Kira Qian
Please mark the replies as answers if they help and unmark if they don't.
Kira Qian  Wednesday, August 12, 2009 3:04 AM
Hi Simple Samples,

Thank you for your feedback. I can reproduce the issue on my side too. Once I use that usercontrol on my form, it won't show any data in DataGridView. To resolve the issue, I added this.testTableAdapter.Fill(dsTest.test); to the usercontrol's constructor, then it can show the data correctly when form load.

I suggest you can post the issue to the Microsoft Connect, so that you can get email feedback to track it.

Sincerely,
Kira Qian
Please mark the replies as answers if they help and unmark if they don't.
Kira Qian  Wednesday, August 12, 2009 3:04 AM
Thank you very much, Kira. Yes, I can do everything you say.

I did already put in the call to the TableAdapter.Fill, except I put the call in the Load event instead of in the constructor. I assume either place will work.

I will create a feedback item in Microsoft Connect. I will post back here after I do.
Sam Hobbs; see my SimpleSamples.Info
Simple Samples  Wednesday, August 12, 2009 4:31 AM
See Code to fill a DataGridView in a UserControl is not generated. I determined that the problem exists for datasources in general, not just TableAdapters. The two might be the same thing; this is something I don't have enough experience in to be sure of what I am saying. I hope the feedback item I created is an accurate description of the problem.
Sam Hobbs; see my SimpleSamples.Info
Simple Samples  Wednesday, August 12, 2009 7:18 AM

You can use google to search for other answers

Custom Search

More Threads

• Checking the data type of dataGridView cell content
• Error in Datagrid column style when setting the ReadOnly property to true!!!
• Problem DataGridView Validation
• DataGrid/Gridview
• sql statment
• dataGrid cell shrinks text when entered
• Modify a DataGridView row , and update the SQL table - datatbase
• Data Validadation of Dates & Numbers
• How to show only 2 decimal places in a text box
• NullReferenceException in Unknown Module when binding 2 checkboxes.