protected void btnAdd_Click(object sender, EventArgs e) { try { if (txtName.Text.Trim().Length > 0 || ddlCountry.SelectedIndex != 0) { state.Name = txtName.Text.Trim(); state.Description = txtDescription.Text.Trim(); state.CountryId = int.Parse(ddlCountry.SelectedValue); state.InsertState(); lblMsg.Text = "State Inserted...!"; BindGridview(); } else { lblMsg.Text = "Plz Select Country...!"; } } catch (Exception) { throw; } }
protected void btnAdd_Click(object sender, EventArgs e) { try { state.Name = txtName.Text.Trim(); state.Description = txtDesc.Text.Trim(); state.CountryId = int.Parse(ddlCountryName.SelectedValue); state.InsertState(); lblMsg.Text = "Inserted...!"; GridView1.DataSource = state.ShowAllState(); GridView1.DataBind(); btnClear_Click(sender, e); } catch (Exception ex) { lblMsg.Text = ex.Message; } }