Adding primary key to the table

Posted by srilakshmi15-4307 under ASP.NET on 1/31/2012 | Points: 10 | Views : 1136 | Status : [Member] | Replies : 1
table.Columns.Add("Id",typeof(int));
int i = 1;
foreach (DataRow drRow in table.Rows)
{
drRow["Id"] = i;
i++;
}
//Row ID --For newly adding slots
table.Columns["Id"].AutoIncrement = true;
table.Columns["Id"].AutoIncrementStep = 1;
table.PrimaryKey = new DataColumn[] { table.Columns["Id"] };

table.AcceptChanges();

DataRow drRow = table.Rows.Find(RowID);//Get selected Grid Row ID//using primary key to delete a row
drRow.Delete();




Responses

Posted by: Blessyjees on: 1/31/2012 [Member] Bronze | Points: 25

Up
0
Down
Hi,

What is your problem.

Blessy Baby
Digitalmesh Softech pvt Ltd
https://blessybaby.wordpress.com/

srilakshmi15-4307, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response