protected void btnSave_Click(object sender, EventArgs e) { #region Server Side Validation lblError.Text = ""; if (txtStateName.Text.Trim().ToUpper() == "") { lblError.Text += "Enter State Name <br/>"; } if (ddlCountry.SelectedValue == "-1") { lblError.Text += "Please Select Country <br/>"; } if (lblError.Text != "") { return; } #endregion Server Side Validation #region Collecting Data StatesENT entState = new StatesENT(); if (ddlCountry.SelectedValue != "-1" && txtStateName.Text.Trim().ToUpper() != "") { entState.StateName = txtStateName.Text.Trim().ToUpper(); entState.CountryID = Convert.ToInt32(ddlCountry.SelectedValue); } StatesBAL balState = new StatesBAL(); #endregion Collecting Data if (Request.QueryString["StateID"] == null) { #region insertingData if (balState.Insert(entState)) { Response.Redirect("~/AdminPanel/State/StateList.aspx"); } else { lblError.Text = balState.Message; } #endregion insertingData } else { #region updatingData entState.StateID = Convert.ToInt32(Request.QueryString["StateID"]); if (balState.Update(entState)) { Response.Redirect("~/AdminPanel/State/StateList.aspx"); } else { lblError.Text = balState.Message; } #endregion updatingData } }
public static void FillDropDownListState(DropDownList ddl) { StatesBAL balState = new StatesBAL(); ddl.DataSource = balState.SelectForDropdownList(); ddl.DataValueField = "StateID"; ddl.DataTextField = "StateName"; ddl.DataBind(); ddl.Items.Insert(0, new ListItem("Select Item", "-1")); }
private void FillGridViewState() { StatesBAL balState = new StatesBAL(); DataTable dtState = new DataTable(); dtState = balState.SelectAll(); if (dtState != null && dtState.Rows.Count > 0) { gvStateList.DataSource = dtState; gvStateList.DataBind(); } }
protected void gvStateList_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandArgument != null) { StatesBAL balState = new StatesBAL(); if (balState.Delete(Convert.ToInt32(e.CommandArgument.ToString().Trim()))) { Response.Redirect("~/Adminpanel/State/StateList.aspx"); lblError.Text = ""; } else { lblError.Text = balState.Message; } } }
private void fillControls(SqlInt32 StateID) { StatesENT entState = new StatesENT(); StatesBAL balState = new StatesBAL(); entState = balState.SelectByPK(StateID); if (entState != null) { if (!entState.StateName.IsNull) { txtStateName.Text = entState.StateName.Value.ToString(); } if (!entState.CountryID.IsNull) { ddlCountry.SelectedValue = entState.CountryID.Value.ToString(); } } else { lblError.Text = balState.Message; } }