根据主健到dataset中去找
object[]findTheseVals = new object[主键数];
findTheseVals[0]=grid中主键1值;
findTheseVals[1]=grid中主键2值;
....
foundRow = dataset.Tables[0].Rows.Find(findTheseVals);

解决方案 »

  1.   

    在dataset中存储的数据与datagrid经过排序后是不会一一对应的推荐使用dataview
    dataview中获得的数据与datagrid经过排序后是一一对应的然后通过this.dataview[this.currentCell.rownum]得到
    的便是你所看到的数据
      

  2.   

    可以用:
    this.datagrid.DataSource = dataSet.Tables[0].DefaultView;
    DefaultView的排序就会根据datagrid的排序.
      

  3.   

    只能根据id寻找,因为dataGrid的排序与dataSet是不同的
    int rowIndex = this.dataGrid.CurrentRowIndex;
    //get id value
    this.dataSet.Tables[0].select( "filter" )
    // select dataRow from dataSet
      

  4.   

    Use the DataKeyField property to specify the key field in the data source indicated by the DataSource property. The specified field is used to populate the DataKeys collection. This allows you to store the key field with a data listing control without displaying it in the control. The key field is commonly used in a handler for an event, such as ItemCommand or DeleteCommand, as part of an update query string to revise a specific record in the data source. The key field helps the update query string identify the appropriate record to modify.
      

  5.   

    你试试自己处理一下,先获得鼠标选中的这一行的primary key(或者能唯一标记这一行的某一列),根据其值在DataSet中找到这一行,然后修改这一行,更新数据库.
    这样做你的修改就不会受到排序的影响,
    不过略麻烦一些