Ver Mensaje Individual
  #1 (permalink)  
Antiguo 19/08/2008, 15:41
joshean
 
Fecha de Ingreso: abril-2008
Mensajes: 26
Antigüedad: 16 años, 1 mes
Puntos: 0
ropDownList SelectedIndexChanged

Hola foreros tengo unos DropDownList que se llenan de la siguinete manera, el DropDownList1 con un SqlDataSource, DropDownList2 y DropDownList3 de unos DataSet que requiere parametros de los DropDownList anteriores algo asi:

Código:
protected void  DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
        {
                    
SqlConnection conexion = new SqlConnection(ConfigurationManager.ConnectionStrings["LineamientosConnectionString"].ConnectionString);
            string ssql;

            ssql = "SELECT id_art, resumen FROM Articulo WHERE contenido = 1 AND id_doc = " + Texto1;

            SqlCommand comando = new SqlCommand(ssql, conexion);
            SqlDataAdapter adaptador = new SqlDataAdapter(comando.CommandText, conexion);

            DataSet ds = new DataSet();
            adaptador.Fill(ds);
            return ds;          

           	this.DropDownList2.DataSource = ds;
            this.DropDownList2.DataValueField = "id_art";
            this.DropDownList2.DataTextField = "id_art";
            this.DropDownList2.DataBind();


        }
        protected void DropDownList2_SelectedIndexChanged(object sender, EventArgs e)
        {
            
            SqlConnection conexion = new SqlConnection(ConfigurationManager.ConnectionStrings["LineamientosConnectionString"].ConnectionString);
            string ssql;
            
            int tipo;
            ds = obj2.LlenaCombo_FraccFracc(DropDownList1.Text, DropDownList2.Text);
            this.DropDownList3.DataSource = ds;
            this.DropDownList3.DataValueField = "tipo";
            this.DropDownList3.DataTextField = "tipo";
            this.DropDownList3.DataBind();

            tipo = Convert.ToInt16(DropDownList3.Text);

            string nomcol;

            nomcol = "";

            if (tipo == 1)
            {
                nomcol = "letra";
            }
            else if (tipo == 2)
            {
                nomcol = "entero";
            }
            else if (tipo == 3)
            {
                nomcol = "romano";
            }

            ssql = "SELECT entero, " + nomcol + " FROM Tipo_fraccion";

            SqlCommand comando2 = new SqlCommand(ssql, conexion);
            SqlDataAdapter adaptador2 = new SqlDataAdapter(comando2.CommandText, conexion);

            DataSet ds2 = new DataSet();
            adaptador2.Fill(ds2);


            this.DropDownList3.DataSource = ds2;
            this.DropDownList3.DataValueField = "entero";
            this.DropDownList3.DataTextField = nomcol;
            this.DropDownList3.DataBind();

        }
el problema es que si el DropDownList2 trae un solo registro no puedo llenar el DropDownList3 por que no aplico su evento SelectedIndexChanged, o si trae mas de uno para llenar el DropDownList3 tengo que elegir algun otro y regresar al primero ,si no lo hago no lo llena.... alguien sabe como puedo solucionarlo, ya lo intentente pegando mi codigo en el load pero me arroja un error....