protected void btnSave_Click(object sender, EventArgs e) { ControllerRepository controllerRep = new ControllerRepository(); int id = Convert.ToInt32(hdnId.Value); if (string.IsNullOrWhiteSpace(txtConName.Text.ToString().Trim())) { lblErrorMsg.Text = "Controller must have name"; lblErrorMsg.ForeColor = Color.Red; lblErrorMsg.Font.Bold = true; txtConName.Focus(); return; } if (ddlTechnology.SelectedIndex == 0) { lblErrorMsg.Text = "Controller must have Technology"; lblErrorMsg.ForeColor = Color.Red; lblErrorMsg.Font.Bold = true; ddlTechnology.Focus(); return; } if (id < 0) { int idController = controllerRep.InsertNewController(GetVaules()); if (idController > 0) { Page.Response.Redirect(Page.Request.Url.ToString(), true); setTextBoxesNull(); } else { setTextBoxesNull(); } } else { bool idController = controllerRep.UpdateController(GetUpdateVaules(id)); if (idController) { Page.Response.Redirect(Page.Request.Url.ToString(), true); DoneOrNot.Text = "Done"; setTextBoxesNull(); } else { DoneOrNot.Text = "You have problem"; setTextBoxesNull(); } } }