guid on DataColumn

  • Thread starter Thread starter Oka Morikawa
  • Start date Start date
O

Oka Morikawa

I'm creating DataTable with DataColumn where I want to use Guid as
Primarykey. The problem is that when I insert new row, I get always the same
Guid as DefaultValue in DataTable where I want that it generates always the
different GUID. How I can accomplish this since DefaultValue =
Guid.NewGuid(); doesn't seem to do the job right.

DataTable dtLamina = new DataTable();
DataColumn myColumn;

myColumn = new DataColumn();
myColumn.DataType = System.Type.GetType("System.Guid");
myColumn.ColumnName = "GUID";
myColumn.DefaultValue = Guid.NewGuid();
dtLamina.Columns.Add(myColumn);

dgLamina.DataSource = dtLamina;
dgLamina.SetDataBinding(dtLamina,"");

Thanks, Oka
 
Back
Top