I have a datatable (dtAmount
) which has two columns [HeadID]
and [Amount]
and I also have a datagridview which has two columns [HeadID]
, [Amount]
and some other columns.
This datagridview has already been bound with a datasource and HeadID
is filled with values but respective Amount
is null. The HeadID
in dtAmount
has the respective values in [Amount]
column and hence I want to开发者_StackOverflow update amount for respective head into datagridview using the values from dtAmount
.
I would suggest you "Merge" function of the DataTable class as follows:
yourDataTable.Merge(dtAmount,true, MissingSchemaAction.Add);
// Merge the specified System.Data.DataTable with the current DataTable, indicating whether to preserve changes and how to handle missing schema in the current DataTable.
精彩评论