////////////////////
DataTable dt = new
DataTable();
//Add columns to DataTable.
dt.Columns.AddRange(new DataColumn[3] { new
DataColumn("Id"),
new DataColumn("Name"), new
DataColumn("Country")
});
//Set AutoIncrement True for the First Column.
dt.Columns["Id"].AutoIncrement
= true;
//Set the Starting or Seed value.
dt.Columns["Id"].AutoIncrementSeed
= 1;
//Set the Increment value.
dt.Columns["Id"].AutoIncrementStep
= 1;
//Add rows to DataTable.
dt.Rows.Add(null, "Raja", "India");
dt.Rows.Add(null, "Ram", "US");
dt.Rows.Add(null, "Mohan", "UK");
dt.Rows.Add(null, "Ray", "Russia");
dt.Rows.Add(null, "Jai", "China");
No comments:
Post a Comment