Visualizzazione dei risultati da 1 a 3 su 3
  1. #1

    Problema con databind su DDL

    ho questa due DDL e i vari sqldatascource:
    codice:
                <td>
                    <asp:DropDownList ID="DropDownList3" runat="server" DataSourceID="SqlDataSource1"
                        DataTextField="descrizione" DataValueField="soluzione#" AutoPostBack="True" AppendDataBoundItems="True"
                        OnSelectedIndexChanged="filtraNetwork">
                        <asp:ListItem Selected="True" Value="0">*</asp:ListItem>
                    </asp:DropDownList>
                    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:MYTELENEWS %>"
                        SelectCommand="SELECT DISTINCT * FROM soluzioni"></asp:SqlDataSource>
                </td>
                <td>
                    <asp:DropDownList ID="DropDownList4" runat="server" DataSourceID="SqlDataSource4"
                        DataTextField="descrizione" DataValueField="gruppo#" AutoPostBack="True" AppendDataBoundItems="True"
                        OnSelectedIndexChanged="filtraGruppi">
                        <asp:ListItem Selected="True" Value="*">*</asp:ListItem>
                    </asp:DropDownList>
                    <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:MYTELENEWS %>"
                        SelectCommand="SELECT * FROM [gruppi] WHERE ([soluzione#] = @ddl3)">
                        <SelectParameters>
                            <asp:ControlParameter ControlID="DropDownList3" DefaultValue="soluzione#" Name="ddl3"
                                PropertyName="SelectedValue" Type="Int32" />
                        </SelectParameters>
                    </asp:SqlDataSource>
                    <asp:SqlDataSource ID="SqlDataSource4" runat="server" ConnectionString="<%$ ConnectionStrings:MYTELENEWS %>"
                        SelectCommand="SELECT * FROM [gruppi]"></asp:SqlDataSource>
                </td>
    vorrei fare che quando sulla prima DDL clicco su un valore diverso dal primo, venga cambiato il DataSource della seconda DDL:
    codice:
            protected void filtraNetwork(object sender, EventArgs e)
            {
                if (DropDownList3.SelectedIndex == 0)
                {
                    DropDownList4.DataSourceID = "SqlDataSource4";
                    DropDownList4.DataBind();
                }
                else
                {
                    DropDownList4.DataSourceID = "SqlDataSource2";
                    DropDownList4.DataBind();
                }
            }
    questo nn funziona, anche se però l'ho usato lo stesso modo sulle GV e li funziona.

  2. #2
    Ciao ... Avevo avuto un problema anche io simile un po' di tempo fa... Avevo risolto utilizzando le CascadingDropDown dell' AjaxControlToolkit...Per non funziona che cosa intendi precisamente ?

  3. #3
    intendevo che nn cambiava il DataSourceID.
    rimaneva sempre lo stesso,
    ma tanto cmq ho cambiato "strategia": le sto riscrivendo tutte da codebehind.
    grazie lo stesso!!

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.