private void AssignRowToSpecsItem(GridViewRow row, DictSpecsItems item) { Control control = row.FindControl("txtCheckDetail"); if (control != null) { item.CheckDetail = (control as TextBox).Text.Trim(); } control = row.FindControl("ddlCheckMethod"); if (control != null) { item.CheckMethod = (control as DropDownList).Text; } control = row.FindControl("txtSpecifiedSizeHeight"); if (control != null) { item.SpecifiedSizeHeight = (control as TextBox).Text.Trim(); } control = row.FindControl("txtKnockPosition"); if (control != null) { item.KnockPosition = (control as TextBox).Text.Trim(); } control = row.FindControl("chkIsFull"); if (control != null) { item.IsFull = (control as CheckBox).Checked; } }
public static List <DictSpecsItems> GetJobDetails(String checkStatus) { List <DictSpecsItems> result = new List <DictSpecsItems>(); string[] list = checkStatus.Split(','); if (list.Length > 0) { foreach (string kv in list) { string[] idcheck = kv.Split('='); if (idcheck.Length == 2) { int id = Int32.Parse(idcheck[0]); String checkResult = idcheck[1].Trim(); Boolean ischeck = checkResult.Substring(0, 1) == "1"?true:false; DictSpecsItems item = null; if (SpecsItems.TryGetValue(id, out item)) { item.IsCheck = ischeck; item.Note = ""; if (checkResult.Length > 2) { item.Note = String.Format("备注:{0}", checkResult.Substring(2, checkResult.Length - 2)); } if (ischeck) { item.ImageUrl = "~/images/icon-checked.gif"; } else { item.ImageUrl = "~/images/icon-cancel.gif"; } result.Add(item); } } } } return(result); }
protected void grdItems_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName.Equals("Add")) { DictSpecsItems item = new DictSpecsItems(); AssignRowToSpecsItem(grdItems.FooterRow, item); item.DictSpecsID = _Entity.ID; if (item.Insert()) { grdItems.EditIndex = -1; BindGrid(); } } if (e.CommandName.Equals("Save")) { int id = Int32.Parse(e.CommandArgument.ToString()); DictSpecsItems item = new DictSpecsItems(); if (item.Find(id)) { AssignRowToSpecsItem(grdItems.Rows[grdItems.EditIndex], item); if (item.Update()) { grdItems.EditIndex = -1; BindGrid(); } } } if (e.CommandName.Equals("Delete")) { int id = Int32.Parse(e.CommandArgument.ToString()); DictSpecsItems item = new DictSpecsItems(); if (item.Find(id)) { if (item.Delete()) { grdItems.EditIndex = -1; BindGrid(); } } } }
private void AssignRowToSpecsItem(GridViewRow row, DictSpecsItems item) { Control control = row.FindControl("txtCheckDetail"); if (control != null) { item.CheckDetail = (control as TextBox).Text.Trim(); } control = row.FindControl("ddlCheckMethod"); if (control != null) { item.CheckMethod = (control as DropDownList).Text; } control = row.FindControl("txtSpecifiedSizeHeight"); if (control!=null) { item.SpecifiedSizeHeight = (control as TextBox).Text.Trim(); } control = row.FindControl("txtKnockPosition"); if (control != null) { item.KnockPosition = (control as TextBox).Text.Trim(); } control = row.FindControl("chkIsFull"); if (control != null) { item.IsFull = (control as CheckBox).Checked; } }
protected void grdItems_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName.Equals( "Add")) { DictSpecsItems item = new DictSpecsItems(); AssignRowToSpecsItem(grdItems.FooterRow, item); item.DictSpecsID = _Entity.ID; if (item.Insert()) { grdItems.EditIndex = -1; BindGrid(); } } if (e.CommandName.Equals("Save")) { int id = Int32.Parse(e.CommandArgument.ToString()); DictSpecsItems item = new DictSpecsItems(); if (item.Find(id)) { AssignRowToSpecsItem(grdItems.Rows[grdItems.EditIndex], item); if (item.Update()) { grdItems.EditIndex = -1; BindGrid(); } } } if (e.CommandName.Equals("Delete")) { int id = Int32.Parse(e.CommandArgument.ToString()); DictSpecsItems item = new DictSpecsItems(); if (item.Find(id)) { if (item.Delete()) { grdItems.EditIndex = -1; BindGrid(); } } } }