protected void BtnSave_Click(object sender, EventArgs e) { LblErr.Text = ""; LblOk.Text = ""; try { TemplateBlock p1 = new TemplateBlock(); if (TxtId.Text == string.Empty) { form2obj(p1); p1 = new TemplateBlocksManager().Insert(p1); } else { p1 = new TemplateBlocksManager().GetByKey(TxtName.Text);//precarico i campi esistenti e nn gestiti dal form form2obj(p1); new TemplateBlocksManager().Update(p1); } Grid1.DataBind(); LblOk.Text = Utility.GetLabel("RECORD_SAVED_MSG"); MultiView1.ActiveViewIndex = 0; } catch (Exception e1) { LblErr.Text = Utility.GetLabel("RECORD_ERR_MSG") + "<br />" + e1.ToString(); } finally { } }
protected void Grid1_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { var item = new TemplateBlock(); item = (TemplateBlock)e.Row.DataItem; LinkButton LnkName = (LinkButton)e.Row.FindControl("LnkName"); LnkName.Text = "<i class='fa fa-pgn_edit fa-fw'></i>"; LnkName.Text += item.Name; } }
private void form2obj(TemplateBlock obj1) { obj1.Name = TxtName.Text; obj1.Title = TxtTitle.Text; obj1.Enabled = ChkEnabled.Checked; }
private void obj2form(TemplateBlock obj1) { TxtName.Text = obj1.Name; TxtTitle.Text = obj1.Title; ChkEnabled.Checked = obj1.Enabled; }
private void edit(string name) { LblOk.Text = ""; LblErr.Text = ""; TxtName.Text = name; TxtName.Enabled = true; TxtTitle.Text = ""; ChkEnabled.Checked = true; TxtId.Text = ""; if (name != "") { TxtId.Text = "1"; TxtName.Enabled = false; TemplateBlock currObj = new TemplateBlock(); currObj = new TemplateBlocksManager().GetByKey(name); obj2form(currObj); } MultiView1.ActiveViewIndex = 1; }