protected void btnAdd_Click(object sender, EventArgs e)
 {
     try
     {
         city.Name        = txtName.Text.Trim();
         city.Description = txtDesc.Text.Trim();
         city.StateId     = int.Parse(ddlStateName.SelectedValue);
         city.InsertCity();
         lblMsg.Text          = "Inserted...!";
         GridView1.DataSource = city.ShowAllCity();
         GridView1.DataBind();
         btnClear_Click(sender, e);
     }
     catch (Exception ex)
     {
         lblMsg.Text = ex.Message.ToString();
     }
 }
示例#2
0
        protected void InsertCity()
        {
            Citytbl ct = new Citytbl();

            ct.CityName    = txtCity.Text;
            ct.StateID     = Convert.ToInt32(ddlState.SelectedValue);
            ct.IsActive    = 1;
            ct.CreatedBy   = 1;
            ct.CreatedDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
            ct.UpdatedBy   = 1;
            ct.UpdatedDate = DateTime.Now.ToString();
            List <Citytbl> lst = new List <Citytbl>();

            lst = objCityBl.InsertCity(ct).ToList();
            ScriptManager.RegisterStartupScript(this, GetType(), "alertMessage", "alertMessage('Data Inserted Successfully');", true);
            btnSave.Visible = true;
            GetCity();
        }