Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Best Practice for Adding a new row to a DataGrid?

Reply
Thread Tools

Best Practice for Adding a new row to a DataGrid?

 
 
Paul
Guest
Posts: n/a
 
      12-25-2003
I have a working system for AutoIncrementing a new row added to a
DataGrid but I keep feeling like it's a kludge. It depends on assigning
a zero to the Primary Key ID field when the row is added to the
DataTable. I use that zero for a couple of things when I go into
EditMode, like setting the RowFilter, etc. The good thing is that zero
is a unique number that would never be duplicated for the row ID of the
table.

I also use zero's existence to tell me whether to sort ASC or DESC for a
DataView sort because of the way it affects finding an index to the
DataTable row.

In the end, the column is set to AutoIncrement and it is mapped to a
Primary Key Identity field in the SQL DB, so the existence of the zero
in a new row isn't really necessary for an update or insert. I just
don't know of a better way to do things. I can't assign it a NULL value
since it's a Primary Key, so it looks like I have to assign it some
integer when I add the new row.

I insert with this zero and it is replaced by the SQL DB by a viable
number for the new row. I read this back in after the insert and
everything is looking good. I just don't trust what I'm doing.

Is this OK or is there a best practice for adding new rows to a grid
that I should know about? Thanks. ~Paul



*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
 
Reply With Quote
 
 
 
Reply

Thread Tools

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
Remember when your piano teacher taught you, "Practice, practice,practice ...?" Wayne Wastier Windows 64bit 3 06-10-2005 08:29 PM
ok I can do a totals row but how about a percentage row after each data row D ASP .Net Datagrid Control 0 05-23-2005 04:10 PM
My addnew row button is only adding one row? Luis Esteban Valencia ASP .Net 0 03-23-2005 04:03 PM
How to add a new row to a datagrid with values of the selected row =?Utf-8?B?U3VyZXNo?= ASP .Net 1 11-22-2004 09:04 AM
I am adding a new row to the datagrid dynamically but if i use the Count property of Item it is not showing the count of the new rows being added Praveen Balanagendra via .NET 247 ASP .Net 2 06-06-2004 07:16 AM



Advertisments