guid on DataColumn

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
 

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