应该不可以,datakeyfield好像是关键字啊,除非是两个字段组成一个关键字!.
up一下吧!

解决方案 »

  1.   

    add an additional column to your DataTable, and use that as the DataKeyField, for exampleDataTable1.Columns.Add("MyNewKey", typeof(string), "keyColumn1 + '#' + keyColumn2");..
    DataGrid1.DataKeyField = "MyNewKey";when you are retrieving it, just split the string into two parts
      

  2.   

    这样看来可以加N个DataKey了 呵呵~
      

  3.   

    s1=((TextBox)e.Item.Cells[4].Controls[4]).Text;
    s2=((TextBox)e.Item.Cells[4].Controls[5]).Text;
      

  4.   

    若我的表中存在两个主键,那改怎样解决此问题,是否应该在dataGrid中定义两个datakeyfield,或有什么更好的解决方法?????
      

  5.   

    我的办法:
    如果是SQLServer,将ID一道select出来,用作主键
    如果是oracle,将ROWID一道select出来,用作主键
    效果都不错,而且简单
      

  6.   

    我做过这样的程序,用一个ViewState就很完美地解决了,当然前提是在一个页面中显示数据和更新,如果是在别的页面更新,那ViewState就用不成了。--------------------------------
    AspNetPager 免费分页控件4.2版发布,同时发布最新源代码,欢迎下载:http://www.webdiyer.com
      

  7.   

    凌晨5点时,急中生智,解决了这个问题:
    select key1+key2 as mainkey,key,key2,key3,....from [mytable]
    ...
    update [mytable] set .... where mainkey=key1+key2