Ver Mensaje Individual
  #4 (permalink)  
Antiguo 11/08/2009, 11:55
Avatar de BlueSkull
BlueSkull
 
Fecha de Ingreso: noviembre-2008
Ubicación: Chile
Mensajes: 504
Antigüedad: 15 años, 6 meses
Puntos: 4
Respuesta: problemas con 3 dropdownlist enlazados

Estimados, estoy cargando los drop con SqlDataSource, pongo el codigo:

ddl1:
Código PHP:
<asp:DropDownList ID="ddl_regiones" runat="server" 
                        
onselectedindexchanged="ddl_regiones_SelectedIndexChanged" Width="200px" 
                        
DataSourceID="dsRegiones" DataTextField="Region" 
                        
DataValueField="IdRegion" AppendDataBoundItems="true">
                        <
asp:ListItem Text="REGIONES" Enabled="true" Value="-1"></asp:ListItem>
                    </
asp:DropDownList>
                    
                    <
asp:SqlDataSource ID="dsRegiones" runat="server" 
                        
ConnectionString="<%$ ConnectionStrings:THERMOPARCORTEConnectionString %>" 
                        
SelectCommand="SELECT [IdRegion], [Region] FROM [Region]">
                    </
asp:SqlDataSource
ddl2:
Código PHP:
<asp:DropDownList ID="ddl_ciudad" runat="server" 
                        
onselectedindexchanged="ddl_ciudad_SelectedIndexChanged" Width="200px" 
                        
DataSourceID="dsCiudades" DataTextField="Ciudad" DataValueField="IdCiudad" 
                        
Enabled="False" AppendDataBoundItems="true">
                        <
asp:ListItem Text="CIUDADES" Enabled="true" Value="-1"></asp:ListItem>
                    </
asp:DropDownList>
                    
                    <
asp:SqlDataSource ID="dsCiudades" runat="server" 
                        
ConnectionString="<%$ ConnectionStrings:THERMOPARCORTEConnectionString %>" 
                        
SelectCommand="SELECT * FROM [Ciudad] WHERE ([IdRegion] = @IdRegion) ORDER BY [Ciudad]">
                        <
SelectParameters>
                            <
asp:ControlParameter ControlID="ddl_regiones" Name="IdRegion" 
                                
PropertyName="SelectedValue" Type="Int32" />
                        </
SelectParameters>
                    </
asp:SqlDataSource
ddl3:
Código PHP:
<asp:DropDownList ID="ddl_comuna" runat="server" Width="200px"
                        
Enabled="False" onselectedindexchanged="ddl_comuna_SelectedIndexChanged" 
                        
DataSourceID="dsComunas" DataTextField="Comuna" 
                        
DataValueField="IdComuna" AppendDataBoundItems="true">
                        <
asp:ListItem Text="COMUNAS" Enabled="true" Value="-1"></asp:ListItem>
                    </
asp:DropDownList>
                    
                    <
asp:SqlDataSource ID="dsComunas" runat="server" 
                        
ConnectionString="<%$ ConnectionStrings:THERMOPARCORTEConnectionString %>" 
                        
SelectCommand="SELECT [IdComuna], [Comuna] FROM [Comuna] WHERE ([IdCiudad] = @IdCiudad) ORDER BY [Comuna]">
                        <
SelectParameters>
                            <
asp:ControlParameter ControlID="ddl_ciudad" Name="IdCiudad" 
                                
PropertyName="SelectedValue" Type="Int32" />
                        </
SelectParameters>
                    </
asp:SqlDataSource
C#:
Código PHP:
protected void ddl_regiones_SelectedIndexChanged(object senderEventArgs e)
    {
        
this.ddl_ciudad.Enabled true;
        
this.ddl_ciudad.Items.Clear();
        
this.ddl_comuna.Items.Clear();
    }

    protected 
void ddl_ciudad_SelectedIndexChanged(object senderEventArgs e)
    {
        
this.ddl_comuna.Enabled true;
        
this.ddl_comuna.Items.Clear();
    }

    protected 
void ddl_comuna_SelectedIndexChanged(object senderEventArgs e)
    {

    } 
Espero que me puedan ayudar ya que aun asi se me duplica la informacion en el ddl3 al cambiar regiones.
__________________
"Incluso las torres más altas empiezan en el suelo."
"Sé Ágil..."
StreamWriter