Datagrid new row

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
 
P

Pete Davis

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
 
G

Gav

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top