Windows Develop Bookmark and Share   
 index > Windows Forms Data Controls and Databinding > UserControl, BindingSource and DataGrid -UPDATED
 

UserControl, BindingSource and DataGrid -UPDATED

Hello,

here's my situation :

I've got a usercontrol, that contains fields generated from dataset by Visual Studio 2005.

I've another dataset that is bind to a DataGrid, always generated using VS2005 drag and drop.

I need to filter the rows of this 2° dataset on IdRubrica, that's the primary key of the user control's bind.

What's the best way to do that? have I to set a foreign key on Table1.IdRubrica -> Table2.IdRubrica??? for loading data, Ive done this way:

private void agendaRubricaBindingSource_CurrentItemChanged(object sender, EventArgs e)

{

DataRowView myRow = (DataRowView)(this.agendaRubricaBindingSource.Current);

int idRubrica = Convert.ToInt32(myRow.Row["IdRubrica"]);

this.agendaTelefoniTableAdapter.Fill(this.agendaTelefoniTDS.AgendaTelefoni, idRubrica);

agendaTelefoniDataGridView.Refresh();

}

I need also to set the values of IdRubrica for INSERT query, how I do that into the binding source?

thanks a lot

Paolo

Paolo Ponzano  Thursday, March 16, 2006 3:03 PM

hello ppl,

I've succeded in, that was my fault, I was missing to set the foreign key and relation constraint! now I can have my DataGrid binded to the user control I need!

I've another question to ask you for, if I add a new item using the "+" button on bindingnavigation toolstrip, and I try to add a row into the datagrid, I receive the message that

"ForeignKeyConstraint FK_AgendaRubrica_AgendaTelefoni requires the child key values (0) to exist in parent table".

I understand that this happens since on Parent Table there's still no the entry wich I'm trying to insert the child of. (is it right in english?? please excuse me if I did a big mistake!).

How can I take care of that (not of my english!)???

thanks a lot

Paolo

Paolo Ponzano  Friday, March 17, 2006 11:59 AM

You can use google to search for other answers

Custom Search

More Threads

• Ctl-0 and datgridview combo
• Custom insert, delete, update
• vb 2005 DataTable
• Prevent invalid data from updating
• Tab Control Data Loss
• Displaying winforms Datagrid in hierarchical
• MVC databinding
• how te get date only?
• Copy Display Text of DatagridViewComboBox to DataGridViewTextBox
• Auto commit in sql server off