protected void rpItems_ItemCommand(object source, RepeaterCommandEventArgs e) { LineItemDAL dal = new LineItemDAL(); if (e.CommandName == "Save") { HiddenField hdId = e.Item.FindControl("hdId") as HiddenField; TextBox txtIntro = e.Item.FindControl("txtIntro") as TextBox; TextBox txtProductName = e.Item.FindControl("txtProductName") as TextBox; TextBox txtSpec = e.Item.FindControl("txtSpec") as TextBox; TextBox txtUnit = e.Item.FindControl("txtUnit") as TextBox; TextBox txtPrice = e.Item.FindControl("txtPrice") as TextBox; TextBox txtQty = e.Item.FindControl("txtQty") as TextBox; TextBox txtRemark = e.Item.FindControl("txtRemark") as TextBox; var lineItem = dal.GetLineItemById(int.Parse(hdId.Value)); lineItem.Intro = txtIntro.Text; lineItem.Name = txtProductName.Text; lineItem.Spec = txtSpec.Text; lineItem.Unit = txtUnit.Text; lineItem.UnitPrice = !string.IsNullOrEmpty(txtPrice.Text) ? double.Parse(txtPrice.Text) : 0; lineItem.Quantity = !string.IsNullOrEmpty(txtQty.Text) ? double.Parse(txtQty.Text) : 0; lineItem.Remark = txtRemark.Text; dal.Save(); } if (e.CommandName == "Delete") { HiddenField hdId = e.Item.FindControl("hdId") as HiddenField; dal.DeleteItem(int.Parse(hdId.Value)); } BindControl(); if (UpdateAmount != null) { UpdateAmount(SourceType, SourceId); } SetFocus(source); }