Datagrid new row

  • Thread starter Thread starter Gav
  • Start date Start date
G

Gav

Hi All,

I have a datagrid that is populated by a strongly typed dataset where ID
must be supplied... when I'm adding a new row in code this isn't a problem
because I can set the ID to whatever I like. However I do not show the ID in
the datagrid so if I type something in the new row of the datagrid then I
get an error saying the ID cannot be null.

Is there a way I can capture that they have entered a new row and set the ID
myself?

Thanks
Gav
 
I think what you'll need to do is handle the DataTable.DataRowChanging
event.

The DataRowAction will be "Add".

If not, look at IBindingList.ListChanged. The DataGrid, internally, treats
the tables as IBindingList, but that ListChanged event may be sent after
you're getting the error.

Pete
 
thanks for that I will give it a try asap.

Pete Davis said:
I think what you'll need to do is handle the DataTable.DataRowChanging
event.

The DataRowAction will be "Add".

If not, look at IBindingList.ListChanged. The DataGrid, internally, treats
the tables as IBindingList, but that ListChanged event may be sent after
you're getting the error.

Pete
 
Back
Top