protected void Page_Load(object sender, EventArgs e) { try { if (!IsPostBack) { string valor = Convert.ToString(Request.QueryString["key"]); if (valor == null) { Response.Redirect("registroterceros.aspx"); } else { ScriptManager.RegisterStartupScript(this, this.GetType(), "hwa", "deletealert();", true); dnitercero.Text = valor; DropDownListpaiscontrato.DataSource = pais.ConsultarPais(); DropDownListpaiscontrato.DataTextField = "pais"; DropDownListpaiscontrato.DataValueField = "idpais"; DropDownListpaiscontrato.SelectedValue = "1"; DropDownListpaiscontrato.DataBind(); cargarDepartamentos(DropDownListpaiscontrato.SelectedValue); DropDownListdepartamentocontrato.SelectedValue = "2"; cargarMunicipios(DropDownListdepartamentocontrato.SelectedValue); DropDownListmunicipiocontrato.SelectedValue = "1"; cargarBarrios(DropDownListmunicipiocontrato.SelectedValue); DropDownListtiporedenciacontrato.DataSource = tpres.ConsultarTipoResidencia(); DropDownListtiporedenciacontrato.DataTextField = "tiporesidencia"; DropDownListtiporedenciacontrato.DataValueField = "idtiporesidencia"; DropDownListtiporedenciacontrato.DataBind(); DropDownListtipocontrato.DataSource = tpoc.ConsultarTipoContrato(); DropDownListtipocontrato.DataTextField = "tipocontrato"; DropDownListtipocontrato.DataValueField = "idtipocontrato"; DropDownListtipocontrato.DataBind(); terc.identificacion = dnitercero.Text; DataRow tercero = Validar.Consulta(terc.ConsultarTerceroDos(terc)).Rows[0]; Label1.Text = tercero["nombre"].ToString(); if (tercero["tipoterceros"].ToString() == "NATURAL" || tercero["tipoterceros"].ToString() == "EMPLEADO") { Label2.Text = tercero["apellido"].ToString(); idsucursallabel.Visible = false; DropDownListsucursalcontrato.Visible = false; } else { if (tercero["tipoterceros"].ToString() == "CORPORATIVO" || tercero["tipoterceros"].ToString() == "ESPECIAL") { Label2.Visible = false; idapellidolabel.Visible = false; cargartablasucursal(tercero["idterceros"].ToString()); } } TextBox1.Text = tercero["direccion"].ToString(); Labelidtercero.Text = tercero["idterceros"].ToString(); cargartabla(Labelidtercero.Text); DataRow cog = contrat.Consultarultimocodigo().Rows[0]; string codgulti = cog["pr_consultarultimocontrat"].ToString(); int codnew = Convert.ToInt32(codgulti) + 1; TextBox4.Text = codnew.ToString(); } } } catch (Exception ex) { textError.InnerHtml = ex.Message; Alerta.CssClass = "alert alert-error"; Alerta.Visible = true; } }