PC Review


Reply
Thread Tools Rate Thread

DataColumn expression to create new Guid

 
 
=?Utf-8?B?TWFyYw==?=
Guest
Posts: n/a
 
      27th Oct 2005
I would like to set up a DataColumn in my table of type Guid and a new
Guid(Guid.NewGuid) would be the expression that gets evaluated when ever a
new row was added. I have the DataSet bound to a grid so I would like to set
this up at compile time. The Guid DataColumn is also the primary key so it
has to be set when a row is added.

Thanks,
Marc
 
Reply With Quote
 
 
 
 
Miha Markic [MVP C#]
Guest
Posts: n/a
 
      28th Oct 2005
Hi Marc,

You might use DataTable.RowChanged event?
Use this code, for example:
if (e.Action == DataRowAction.Add)
e.Row["Guid"] = Guid.NewGuid();

--
Miha Markic [MVP C#]
RightHand .NET consulting & development www.rthand.com
Blog: http://cs.rthand.com/blogs/blog_with_righthand/

"Marc" <(E-Mail Removed)> wrote in message
news:FBBB3462-C2E7-4122-B71C-(E-Mail Removed)...
>I would like to set up a DataColumn in my table of type Guid and a new
> Guid(Guid.NewGuid) would be the expression that gets evaluated when ever a
> new row was added. I have the DataSet bound to a grid so I would like to
> set
> this up at compile time. The Guid DataColumn is also the primary key so
> it
> has to be set when a row is added.
>
> Thanks,
> Marc



 
Reply With Quote
 
=?Utf-8?B?TWFyYw==?=
Guest
Posts: n/a
 
      28th Oct 2005
Thanks,

Marc

"Miha Markic [MVP C#]" wrote:

> Hi Marc,
>
> You might use DataTable.RowChanged event?
> Use this code, for example:
> if (e.Action == DataRowAction.Add)
> e.Row["Guid"] = Guid.NewGuid();
>
> --
> Miha Markic [MVP C#]
> RightHand .NET consulting & development www.rthand.com
> Blog: http://cs.rthand.com/blogs/blog_with_righthand/
>
> "Marc" <(E-Mail Removed)> wrote in message
> news:FBBB3462-C2E7-4122-B71C-(E-Mail Removed)...
> >I would like to set up a DataColumn in my table of type Guid and a new
> > Guid(Guid.NewGuid) would be the expression that gets evaluated when ever a
> > new row was added. I have the DataSet bound to a grid so I would like to
> > set
> > this up at compile time. The Guid DataColumn is also the primary key so
> > it
> > has to be set when a row is added.
> >
> > Thanks,
> > Marc

>
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
DataColumn.Expression Andrzej Kaczmarczyk Microsoft ADO .NET 3 17th Oct 2005 03:22 PM
DataColumn Expression Q Vai2000 Microsoft C# .NET 1 4th Mar 2005 02:00 PM
guid on DataColumn Oka Morikawa Microsoft Dot NET Framework Forms 0 12th Feb 2004 09:50 AM
New GUID(guidstring) fails to create GUID - Help Please!!! Chris Ericoli Microsoft Dot NET 1 29th Oct 2003 06:04 AM
DataColumn.Expression Rodrigo Microsoft ADO .NET 1 7th Oct 2003 07:36 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:10 PM.