add another column to your data tableYourDataTable("MyKey", typeof(string), "key1 + '#' + key2 + '#' + key3");you might need to convert your key to a string type, for example YourDataTable("MyKey", typeof(string), "Convert(key1,'System.String') + '#' + key2 + '#' + key3");YourDataGrid.DataKeyField = "MyKey"; ...string [] slist = YourDataGrid.DataKeys[YourItemIndex].ToString().Split('#');
---maybe sql select 培训班名称+期数+教师姓名 as '三个字段' from yourTable
--添加多列主键 alter table dbo.yourTable Add Constraint pk_yourTable PRIMARY KEY (培训班名称,期数,教师姓名)
select 培训班名称+期数+教师姓名 as 'MyPrimaryKey' from yourTable
YourDataTable("MyKey", typeof(string), "Convert(key1,'System.String') + '#' + key2 + '#' + key3");YourDataGrid.DataKeyField = "MyKey";
...string [] slist = YourDataGrid.DataKeys[YourItemIndex].ToString().Split('#');
select 培训班名称+期数+教师姓名 as '三个字段' from yourTable
alter table dbo.yourTable
Add Constraint pk_yourTable PRIMARY KEY (培训班名称,期数,教师姓名)