protected void imgBtnAdd_Click(object sender, ImageClickEventArgs e) { try { DataTable dtparam = new DataTable(); dtparam.Columns.Add("param", typeof(string)); dtparam.Columns.Add("stv", typeof(string)); int j = 0; foreach (GridViewRow gr in GVTestparameters.Rows) { string param = ((TextBox)gr.FindControl("txtParam")).Text.Trim(); string stv = ((TextBox)gr.FindControl("txtStdVal")).Text.Trim(); if (param != "" && stv != "") { dtparam.Rows.Add(); dtparam.Rows[j]["param"] = ((TextBox)gr.FindControl("txtParam")).Text.Trim(); dtparam.Rows[j]["stv"] = ((TextBox)gr.FindControl("txtStdVal")).Text.Trim(); j++; } } dtparam.Rows.Add(); GVTestparameters.DataSource = dtparam; GVTestparameters.DataBind(); } catch (Exception ex) { ExceptionLogging.SendExcepToDB(ex, Session["UsrName"].ToString(), Request.ServerVariables["REMOTE_ADDR"].ToString()); cf.ShowAlertMessage(ex.ToString()); } }
protected void GVTestparameters_RowCommand(object sender, GridViewCommandEventArgs e) { try { if (e.CommandName == "Remove") { GridViewRow gvrow = (GridViewRow)((Control)e.CommandSource).NamingContainer; DataTable dtparam = new DataTable(); dtparam.Columns.Add("param", typeof(string)); dtparam.Columns.Add("stv", typeof(string)); int j = 0; foreach (GridViewRow gr in GVTestparameters.Rows) { dtparam.Rows.Add(); dtparam.Rows[j]["param"] = ((TextBox)gr.FindControl("txtParam")).Text.Trim(); dtparam.Rows[j]["stv"] = ((TextBox)gr.FindControl("txtStdVal")).Text.Trim(); j++; } dtparam.Rows.RemoveAt(gvrow.RowIndex); if (dtparam.Rows.Count == 0) { dtparam.Rows.Add(); } GVTestparameters.DataSource = dtparam; GVTestparameters.DataBind(); } } catch (Exception ex) { ExceptionLogging.SendExcepToDB(ex, Session["UsrName"].ToString(), Request.ServerVariables["REMOTE_ADDR"].ToString()); cf.ShowAlertMessage(ex.ToString()); } }
protected void CreateRow() { DataTable dtparam = new DataTable(); dtparam.Columns.Add("param", typeof(string)); dtparam.Columns.Add("stv", typeof(string)); dtparam.Rows.Add(); GVTestparameters.DataSource = dtparam; GVTestparameters.DataBind(); }