protected void CountryAddButton_Click(object sender, EventArgs e) { try { if (CountryNameTextBox.Text.Trim().Length == 0) { System.Windows.Forms.MessageBox.Show(new System.Windows.Forms.Form { TopMost = true }, "Don't accept Space char in your name"); Focus(); } CPT_CountryMaster Countrydetails = new CPT_CountryMaster(); Countrydetails.RegionID = Convert.ToInt32(RegionList.SelectedValue); Countrydetails.CountryName = CountryNameTextBox.Text.Trim(); Countrydetails.IsActive = true; CountryMasterBL insertCountry = new CountryMasterBL(); insertCountry.Insert(Countrydetails); BindGrid(); CleartextBoxes(this); } catch (Exception ex) { Console.WriteLine(ex.Message); } }
private void BindGrid() { List <CPT_CountryMaster> lstCountry = new List <CPT_CountryMaster>(); CountryMasterBL clsCountry = new CountryMasterBL(); lstCountry = clsCountry.getCountry(); gvCountry.DataSource = lstCountry; gvCountry.DataBind(); }
protected void delete(object sender, GridViewDeleteEventArgs e) { CPT_CountryMaster Countrydetails = new CPT_CountryMaster(); int id = int.Parse(gvCountry.DataKeys[e.RowIndex].Value.ToString()); Countrydetails.CountryMasterID = id; CountryMasterBL deleteCountry = new CountryMasterBL(); deleteCountry.Delete(Countrydetails); BindGrid(); }
protected void update(object sender, GridViewUpdateEventArgs e) { try { CPT_CountryMaster Countrydetails = new CPT_CountryMaster(); int id = int.Parse(gvCountry.DataKeys[e.RowIndex].Value.ToString()); Countrydetails.CountryMasterID = id; string CountryName = ((TextBox)gvCountry.Rows[e.RowIndex].Cells[2].Controls[0]).Text; Countrydetails.CountryName = CountryName; CountryMasterBL updateCountry = new CountryMasterBL(); updateCountry.Update(Countrydetails); gvCountry.EditIndex = -1; BindGrid(); } catch (Exception ex) { Console.WriteLine(ex.Message); } }