DataGrid and SQL GUID Column

  • Thread starter Thread starter Leon
  • Start date Start date
L

Leon

Hi,
I have SQL DB table with a GUID Primary key. i used the C#
data form wizard to create a data form (though has a typed
dataset) with a Grid (the GUID column is not shown on the
grid). when the user adds a new row at the end of rows in
the grid (, types data in) and moves to another row the
error message appears: "primary key cant be null". what
should i do to make the system generate a new GUID for the
primary key column in the newly added row? (the default
value for the PK column is (newid()). but no default value
in the dataset properties) what event or default value i
should use?
thank you very much in advace.
 
Leon,

In this case, you are going to have to hook into the Grid and find out
before the current row is changed (probably through the CellChanged event).
Once you have that, you will have to set the column in the data set to a new
guid value.

Hope this helps.
 
Back
Top