keerthi

keerthi

  • NA
  • 3
  • 1.5k

Query regarding Updating record

Oct 13 2011 5:35 AM

I have written procedure for updating country including already exist.

While running the code, if a record is updated it is "showing record updated successfuly" and when another record is updated with the same name in the list record is not updated but the message is showing "record updated successfully". Find the below c# code which I have written

protected void btnSave_Click(object sender, EventArgs e)
{
Country objCountry = new Country();
CountryBAL objCountryBal = new CountryBAL();
objCountry.CountryName = txtCountryName.Text;
objCountry.Status = Convert.ToInt16(ddlStatus.SelectedValue);
if (ViewState["Id"] != null)
{
if (!string.IsNullOrEmpty(ViewState["Id"].ToString()))
{
objCountry.CountryId = Convert.ToInt32(ViewState["Id"]);
bool status = (new CountryBAL().UpdateCountry(objCountry));
if (status == true)
{
BindCountry();
tabErrMess.Visible = true;
lblMessage.Text = "Record Updated Successfully";
txtCountryName.Text = "";
ViewState["Id"] = null;
}
else
{
tabErrMess.Visible = true;
lblMessage.Text = "Updatation Failed";
ImgMsg.Visible = false;
}
}
}

Answers (5)