Windows Develop Bookmark and Share   
 index > Windows Forms Data Controls and Databinding > data on a usercontrol
 

data on a usercontrol

Hello,

In a project I use an access database (with some record in a
table). With VS2005 IDE,
I created a datasources. When I drag and drop a table from the "data
sources" window a datagridview
is created. Normal.

When I do exactly the same thing on a UserControl, I see the Datagridview
but no data and when I drop the
user control on a form, I see the datagridview but no data. I can see the
header columns but no data.

Do you have an idea what I can do ?


Regards,

fuatson  Thursday, August 09, 2007 10:00 AM

Hi fuatse,

It is because that the UserControl designer donot add aUserControl.Load event for this data source. You need add the event manually for your customized UserControl. Try something like the following.

private void DataUc_Load(object sender, EventArgs e)

{

this.testTableAdapter.Fill(this.dataSet1.test);//use your own TableAdapter and DataSet

}

Hope this helps.

Regards.

Rong-Chun Zhang  Monday, August 13, 2007 9:30 AM

Hi fuatse,

It is because that the UserControl designer donot add aUserControl.Load event for this data source. You need add the event manually for your customized UserControl. Try something like the following.

private void DataUc_Load(object sender, EventArgs e)

{

this.testTableAdapter.Fill(this.dataSet1.test);//use your own TableAdapter and DataSet

}

Hope this helps.

Regards.

Rong-Chun Zhang  Monday, August 13, 2007 9:30 AM
Simple Samples  Monday, August 17, 2009 5:01 AM

You can use google to search for other answers

Custom Search

More Threads

• GridView codeless Paging and Sorting
• Binding.Parse occurring before Validating
• No overload for method 'ExecuteNonQuery' takes '1' arguments
• DBNull error
• 2 DataTables related through third
• DataGridView EditingControlShowing event opposite?
• Rowediting does not work?
• Commit changes to database
• DataGridView questions
• How to remove sorting for one column in Gridview