Windows Develop Bookmark and Share   
 index > Windows Forms Data Controls and Databinding > Datagridview - OnRowInsert
 

Datagridview - OnRowInsert

Hi all.

I have a problem. I need to lookup a record in another DataTable when i do a rowinsert in a grid.
But if i create a event for RowInsert this events gets fired to many times when the grid is being populated. (I get my data from a progress db og all my data is in "dataset.tables[0]."

For instance. If i have a datatable with 5 rows in it i would like this event to be fired for each 5 rows. this does not happend. It fires this event for empty rows without any binding and when openting the form. Why? and how can i make the code so that the event only fires if valid data is to be shown?

//Create a few extra fields in my datagrid. (must be done in grid. The binding table must be untouched)
//new columns
int newIndex;
newIndex =
this.dgvSelectedTable.Columns.Add("Code", "Code");
newIndex =
this.dgvSelectedTable.Columns.Add("Description", "Description");

Datagrid1.DataSource = progressDataSet.Tables[0]; //this dataset has only on
e table with columns "ProductObj,ContractObj"

How can i prevent this event to be fired if row is empty or not binded to a table?

Thanks.

Lars E.Nes  Friday, October 06, 2006 7:13 AM
Why not use the DataGridView's DefaultValuesNeeded event instead?
Ken Tucker  Friday, October 06, 2006 4:03 PM
Why not use the DataGridView's DefaultValuesNeeded event instead?
Ken Tucker  Friday, October 06, 2006 4:03 PM

You can use google to search for other answers

Custom Search

More Threads

• POSTAL CODE
• how to implement ShowCellErrors in DataGridView vb.net.
• RowFilter property of the RelatedDataView
• ADO.NET 2-tiers Form schema
• How to execute a store procedure in C#?
• FILTER THE VALUES ON PARAMETERS
• find a string in datagridview
• winform datagrid error
• Selecting a DataGridView row programatically
• My row headers won't display.