你有把DropDownList2的AutoPostBack設為true嗎

解决方案 »

  1.   

    要想实现联动必须把DropDownList的AutoPostBack属性设置true,这样才能回传服务器,获得数据
      

  2.   

    代码没错,应该是1楼的问题,或者SQL查询根本查不到数据
    不过建议DataSet用完要dispose()掉,占缓存资源
      

  3.   

    参考:http://download.csdn.net/source/331627http://download.csdn.net/source/282546
      

  4.   

    DataBind() 
    你这个函数时放在pageload里面的么,如果是,那么有没有写if(!this.page.ispostback){DataBind(); }
      

  5.   

    选择第一个DropDownList是否页面有刷新的迹象?
      

  6.   

    <td style="text-align: right;">分类1:</td>
                                        <td style="width :220px;text-align: left">
                                            <asp:DropDownList ID="ddlclass1" runat="server" AutoPostBack="True" DataSourceID="SqlDataSource1"
                                                DataTextField="RSS_CLASS_NAME" DataValueField="RSS_CLASS_ID" Width="101px" OnSelectedIndexChanged="ddlclass1_SelectedIndexChanged" >
                                            </asp:DropDownList>
                                            <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:RSSConnectionString %>"
                                                SelectCommand="SELECT RSS_CLASS_ID, RSS_CLASS_NAME, RSS_CLASS_SERIES, RSS_FATHER_ID FROM RSS_CLASS WHERE (RSS_FATHER_ID = @fatherID) AND (RSS_CLASS_SERIES = @seriesID) OR (RSS_CLASS_ID = @classID2) ORDER BY RSS_CLASS_ID"
                                                ProviderName="<%$ ConnectionStrings:RSSConnectionString.ProviderName %>">
                                                <SelectParameters>
                                                    <asp:Parameter DefaultValue="000" Name="fatherID" />
                                                    <asp:Parameter DefaultValue="1" Name="seriesID" />
                                                    <asp:Parameter DefaultValue="000" Name="classID2" />
                                                </SelectParameters>
                                            </asp:SqlDataSource>                               
                                        </td>                                   
                                        <td style="text-align: right">分类2:</td>
                                        <td style="width :220px;text-align: left">
                                           <asp:DropDownList ID="ddlclass2" runat="server" AutoPostBack="True" DataSourceID="SqlDataSource2"
                                                DataTextField="RSS_CLASS_NAME" DataValueField="RSS_CLASS_ID" Width="101px" >
                                            </asp:DropDownList>
                                            <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:RSSConnectionString %>"
                                                SelectCommand="SELECT RSS_CLASS_ID, RSS_CLASS_NAME, RSS_FATHER_ID, RSS_CLASS_SERIES FROM RSS_CLASS WHERE (RSS_FATHER_ID = @fatherID) AND (RSS_CLASS_SERIES = @series) OR (RSS_CLASS_ID = @classId2) ORDER BY RSS_CLASS_ID"
                                                ProviderName="<%$ ConnectionStrings:RSSConnectionString.ProviderName %>">
                                                <SelectParameters>
                                                    <asp:ControlParameter ControlID="ddlclass1" Name="fatherID" PropertyName="SelectedValue" />
                                                    <asp:Parameter DefaultValue="2" Name="series" />
                                                    <asp:Parameter DefaultValue="000" Name="classId2" />
                                                </SelectParameters>
                                            </asp:SqlDataSource>
                                        </td>                                   
                                        <td style="text-align: right">分类3:</td>
                                        <td style="width :210px;text-align: left">
                                              <asp:DropDownList ID="ddlclass3" runat="server" AutoPostBack="True" DataSourceID="SqlDataSource3"
                                                DataTextField="RSS_CLASS_NAME" DataValueField="RSS_CLASS_ID" Width="101px">
                                            </asp:DropDownList>                                     
                                            <asp:SqlDataSource ID="SqlDataSource3" runat="server" ConnectionString="<%$ ConnectionStrings:RSSConnectionString %>"
                                                ProviderName="<%$ ConnectionStrings:RSSConnectionString.ProviderName %>" SelectCommand="SELECT RSS_CLASS_ID, RSS_CLASS_NAME, RSS_FATHER_ID, RSS_CLASS_SERIES FROM RSS_CLASS WHERE (RSS_FATHER_ID = @fatherID AND RSS_CLASS_SERIES = @seriesID)&#13;&#10;OR (RSS_CLASS_ID = @classId2) ORDER BY RSS_CLASS_ID">
                                                <SelectParameters>
                                                    <asp:ControlParameter ControlID="ddlclass2" Name="fatherID" PropertyName="SelectedValue" />
                                                    <asp:Parameter DefaultValue="3" Name="seriesID" />
                                                    <asp:Parameter DefaultValue="000" Name="classId2" />
                                                </SelectParameters>
                                            </asp:SqlDataSource>
      
    *****************************************************************************
    欢迎使用CSDN论坛专用阅读器 : CSDN Reader(附全部源代码) http://www.cnblogs.com/feiyun0112/archive/2006/09/20/509783.html
      

  7.   

    你的 DropDownList2 selectindexchanged事件触发时,是否可以进入此事件对应的你写的函数