DataRow row=null;
DataTable table=null;
object key=e.Cell.Row.DataKey;

table=dataSet31.Tables[e.Cell.Band.BaseTableName]; //Try to find the row that needs to be updated.
if (key!=null) 
row=table.Rows.Find(key);
在调试状态下 发现key有值,但row=table.Rows.Find(key)就取不出来...
需要什么特殊设置么?

解决方案 »

  1.   

    开始你怎么给  Row.DataKey 负值的
      

  2.   

    does your table have a primary key? and one of the values for the primary key is in your key variable?or just tryDataRow[] drs = table.Select("YourColumn='" + key.ToString() + "'");
      

  3.   

    to goody9807() 
    没给Row.DataKey赋过值啊,默认的to Paradise_heida(学海无涯,回头是岸!) 
    key为行数  结果是1,2什么的
      

  4.   

    to  saucer(思归)
    有主键,但是就是得不到ROW
      

  5.   

    就这些了,不知道差那里
    private void Page_Load(object sender, System.EventArgs e)
    {
    // Put user code to initialize the page here
    if(!this.IsPostBack)
    {
    //UltraWebGrid1.DisplayLayout.AllowUpdateDefault=AllowUpdate.Yes;
    UltraWebGrid1.DataSource=dataSet31.Tables["stationmanual"].DefaultView; 
    sqlDataAdapter1.SelectCommand = new SqlCommand("select * from stationmanual", sqlConnection1);
    sqlDataAdapter1.Fill(dataSet31);
    UltraWebGrid1.DataBind();
    }
    }private void UltraWebGrid1_UpdateCellBatch(object sender, Infragistics.WebUI.UltraWebGrid.CellEventArgs e)
    {
    DataRow row;
    DataTable table=null;
    object key=e.Cell.Row.DataKey;

    table=dataSet31.Tables[e.Cell.Band.BaseTableName]; //Try to find the row that needs to be updated.
    if (key!=null)
    row=table.Rows.Find(key);
    //Try to update the cell in this row.
    if(row!=null) 
    {
    try
    {
    object newVal=e.Cell.Value;
    row[e.Cell.Column.Key]=newVal;
    }
    catch(Exception ex)
    {
    Console.WriteLine(ex.Message);
    dataSet31.RejectChanges();
    }
    }
    }
      

  6.   

    >>>if(!this.IsPostBack)where did you save the DataSet? how does the primary key get defined?>>有主键,但是就是得不到ROWyou mean your table in the database has a primary key?
    sqlDataAdapter1.MissingSchemaAction = MissingSchemaAction.AddWithKey;
    sqlDataAdapter1.SelectCommand = ...