protected void BindGrid() { try { objBE.Action = "R"; objBE.Dept = Department; dt = ObjDL.TestIUDR(objBE, con); if (dt.Rows.Count > 0) { GvTest.DataSource = dt; GvTest.DataBind(); } else { GvTest.DataSource = null; GvTest.DataBind(); cf.ShowAlertMessage("No Data"); } } catch (Exception ex) { ExceptionLogging.SendExcepToDB(ex, Session["UsrName"].ToString(), Request.ServerVariables["REMOTE_ADDR"].ToString()); cf.ShowAlertMessage(ex.ToString()); } }
protected void BindGrid() { check(); try { dt = new DataTable(); objBE.CatId = ddlSamCat.SelectedValue; objBE.Action = "R"; dt = ObjDL.TestParameterIUDR(objBE, con); if (dt.Rows.Count > 0) { GvTest.DataSource = dt; GvTest.DataBind(); GvTest.Visible = true; } else { DataTable dtparam = new DataTable(); dtparam.Columns.Add("Parameter", typeof(string)); dtparam.Rows.Add(); GVTestParam.DataSource = dtparam; GVTestParam.DataBind(); GvTest.Visible = false; } BtnSave.Visible = true; } catch (Exception ex) { ExceptionLogging.SendExcepToDB(ex, Session["UsrName"].ToString(), Request.ServerVariables["REMOTE_ADDR"].ToString()); Response.Redirect("~/Error.aspx"); } }
protected void GvTest_RowDeleting(object sender, GridViewDeleteEventArgs e) { Label ParaId = (Label)GvTest.Rows[e.RowIndex].FindControl("lblparamid"); objBE.ParamID = ParaId.Text; objBE.Action = "D"; DataTable dt = new DataTable(); dt = ObjDL.TestParameterIUDR(objBE, con); if (dt.Rows.Count > 0) { ObjCommon.ShowAlertMessage("Data Not Deleted"); } else { GvTest.DataSource = dt; GvTest.DataBind(); BindGrid(); } }
protected void GvTest_RowUpdating(object sender, GridViewUpdateEventArgs e) { Label ParaId = (Label)GvTest.Rows[e.RowIndex].FindControl("lblparamids"); TextBox paraName = (TextBox)GvTest.Rows[e.RowIndex].FindControl("txtParam"); objBE.ParamID = ParaId.Text; objBE.ParamName = paraName.Text; objBE.Action = "U"; DataTable dt = new DataTable(); dt = ObjDL.TestParameterIUDR(objBE, con); if (dt.Rows.Count > 0) { ObjCommon.ShowAlertMessage("Data Not Updated"); } else { GvTest.DataSource = dt; GvTest.DataBind(); GvTest.EditIndex = -1; BindGrid(); } }