将三个字段一起设为DataKeyField吗?

解决方案 »

  1.   

    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('#');
      

  2.   

    ---maybe sql 
    select 培训班名称+期数+教师姓名 as '三个字段' from yourTable
      

  3.   

    --添加多列主键
    alter table dbo.yourTable
    Add Constraint pk_yourTable PRIMARY KEY (培训班名称,期数,教师姓名)
      

  4.   

    select 培训班名称+期数+教师姓名 as 'MyPrimaryKey' from yourTable
      

  5.   

    why not have a try?