protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { MyJobPortalModel.Country ObjCountryName = new MyJobPortalModel.Country(int.Parse(e.Row.Cells[1].Text)); e.Row.Cells[1].Text = ObjCountryName.CountryName; } }
protected void LnkBtnEditCountry_Click(object sender, EventArgs e) { EditCountryModal.Visible = true; TxtCountryNameEdit.Focus(); this.Form.DefaultButton = BtnGo.UniqueID; GridViewRow ObjCurrentRow = (GridViewRow)((LinkButton)sender).Parent.Parent; int Id = (int)GridView1.DataKeys[ObjCurrentRow.RowIndex]["Id"]; HdnCountryId.Value = Id.ToString(); MyJobPortalModel.Country ObjCountry = new MyJobPortalModel.Country(Id); TxtCountryNameEdit.Text = ObjCountry.CountryName; }
protected void BtnUpdateCountry_Click(object sender, EventArgs e) { if (this.IsValid == true) { bool AllOk = true; if ((int)MyJobPortalModel.Country.GetCountryRecords("CountryName='" + TxtCountryNameEdit.Text + "' and Id<>" + int.Parse(HdnCountryId.Value)).Rows.Count > 0) { LblDuplicateCountryNameError.Visible = true; AllOk = false; } if (AllOk == true) { MyJobPortalModel.Country ObjCountry = new MyJobPortalModel.Country(int.Parse(HdnCountryId.Value)); ObjCountry.CountryName = TxtCountryNameEdit.Text; ObjCountry.Status = DdlStatusEdit.SelectedValue; ObjCountry.Update(); EditCountryModal.Visible = false; LblMessage.Text = "" + TxtCountryNameEdit.Text + " has been updated"; ShowGridView(); } } }