2012-05-02 12 views

答えて

0

iがtelerikによって提供された例を、以下、次のように変更することによって、このタスクを達成:

protected void RadGridProductionOrders_UpdateCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e) 
    { 
     GridEditableItem editedItem = e.Item as GridEditableItem; 
     UserControl userControl = (UserControl)e.Item.FindControl(GridEditFormItem.EditFormUserControlID); 
     ProductionOrderDetail productionOrderDetail = new ProductionOrderDetail(); 
     ProductionDataContext db = new ProductionDataContext(); 

     productionOrderDetail = (from p in db.ProductionOrderDetails 
           where p.orderNo == editedItem.OwnerTableView.DataKeyValues[editedItem.ItemIndex]["orderNo"] 
            && p.itemCode == editedItem.OwnerTableView.DataKeyValues[editedItem.ItemIndex]["itemCode"] 
           select p).Single(); 

     productionOrderDetail.qty = int.Parse((userControl.FindControl("TextBoxQty") as TextBox).Text); 

     try 
     { 
      db.SubmitChanges(); 
     } 
     catch(Exception ex) 
     { 
      Label lblError = new Label(); 

      lblError.Text = "Unable to update Production Order data. Reason: " + ex.Message; 
      lblError.ForeColor = System.Drawing.Color.Red; 

      RadGridProductionOrders.Controls.Add(lblError); 

      e.Canceled = true; 
     } 
} 

このコードは、グリッドを新しい値で更新され完了した後。

関連する問題