protected void Button1_Click(object sender, EventArgs e)
    {
        this.SqlDataSourceServicios.SelectParameters["Cod_servicio"].DefaultValue = this.TextBox1.Text;

        this.SqlDataSourceServicios.DataSourceMode = SqlDataSourceMode.DataReader;

        SqlDataReader registros;

        registros = (SqlDataReader)SqlDataSourceServicios.Select(DataSourceSelectArguments.Empty);

        if (registros.Read())
        {
            this.TextBox2.Text =
                registros["Desc_servicio"].ToString();

            this.DropDownList2.SelectedValue =
                registros["Tipo_servicio"].ToString();

            this.DropDownList1.SelectedValue =
                registros["Rubro"].ToString();

            // this.DropDownList2.DataSource =
            //this.SqlDataTipo;

            //this.DropDownList1.DataSource =
            //this.SqlDataSourceRubros;

            this.DropDownList1.DataTextField = "Desc_rubro";

            this.DropDownList1.DataValueField = "Cod_rubro";

            this.DropDownList2.DataTextField = "Desc_serv";

            this.DropDownList2.DataValueField = "Cod_serv";

            this.DropDownList1.DataBind();
            this.DropDownList2.DataBind();
        }

        else
        {
            this.Label1.Text = "No existe el servicio con dicho código";
        }
    }
示例#2
0
        protected void ButtonAlta_Click(object sender, EventArgs e)
        {
            int num = 0;

            if (num < 4)
            {
                SqlDataSourceServicios.InsertParameters["nomServicio"].DefaultValue  = TextBoxNombreServicio.Text;
                SqlDataSourceServicios.InsertParameters["descServicio"].DefaultValue = TextBoxDescServicio.Text;
                SqlDataSourceServicios.Insert();

                Label4.Text = "Servicio agregado con éxito";
                TextBoxNombreServicio.Text = "";
                TextBoxDescServicio.Text   = "";
                num++;
            }

            else
            {
                Label4.Text = "No se admiten más servicios";
            }
        }