|
如果数据绑定的ID 是long 类型,获取选中行的ID的值,会被改变。
比如:
DataTable table = new DataTable();
table.Columns.Add(new DataColumn("Id", typeof(long)));
table.Columns.Add(new DataColumn("Name", typeof(String)));
table.Columns.Add(new DataColumn("EntranceYear", typeof(String)));
table.Columns.Add(new DataColumn("AtSchool", typeof(bool)));
table.Columns.Add(new DataColumn("Major", typeof(String)));
table.Columns.Add(new DataColumn("Group", typeof(int)));
table.Columns.Add(new DataColumn("Gender", typeof(int)));
table.Columns.Add(new DataColumn("LogTime", typeof(DateTime)));
table.Columns.Add(new DataColumn("Desc", typeof(string)));
table.Columns.Add(new DataColumn("Guid", typeof(Guid)));
table.Columns.Add(new DataColumn("Hobby", typeof(String)));
// Hobby:reading,basketball,travel,movie,music
// 爱好:读书, 篮球, 旅游, 电影, 音乐
// [[4748893713746522227], [1598382814824138521], [7115545863263662460], [-6365282757019369465], [-8289479567123093980]]
DataRow row = table.NewRow();
row[0] = 4748893713746522227;
row[1] = "陈萍萍";
row[2] = "2000";
row[3] = true;
row[4] = "计算机应用技术";
row[5] = 1;
row[6] = 0;
row[7] = DateTime.Now.AddDays(-100);
row[8] = "陈萍萍,女,20岁,出生于中国南方的一个小山村,毕业于中国科学技术大学。";
row[9] = new Guid();
row[10] = "reading,basketball,travel";
table.Rows.Add(row);
row = table.NewRow();
row[0] = 1598382814824138521;
row[1] = "胡飞";
row[2] = "2008";
row[3] = false;
row[4] = "信息工程";
row[5] = 1;
row[6] = 1;
row[7] = DateTime.Now.AddDays(-90);
row[8] = "胡飞,男,20岁,出生于中国北方的一个小山村,毕业于南方科学技术大学。";
row[9] = new Guid();
row[10] = "reading,basketball";
table.Rows.Add(row);
在获取行的ID值的时候,
object[] keys = Grid1.DataKeys[e.RowIndex];获取到的值是 4748893713746522000; 而不是原来的值
row[0] = 4748893713746522227;
|
|