GridView:
Set the property: DataKeyNames, common to set as primary key for identity, and don't need to use DataSource component(e.g. SqlDataSource), as common, just the DataSource property of GridView, and you can use GridView1.DataKeys[e.NewSelectedIndex].Value to get the value.
转载于:https://www.cnblogs.com/jerryhong/archive/2008/05/21/1204070.html