autopost返回无法在asp.net的更新面板中工作

时间:2013-12-17 15:33:47

标签: asp.net asp.net-mvc vb.net reference refresh

我的网络存在问题

我的页面在更新面板中包含3个下拉列表,每个下拉列表都有autopost back属性,但autopost不会运行。

我的页面是

<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Always"  ChildrenAsTriggers="true">

                                 <Triggers>

   <asp:AsyncPostBackTrigger ControlID="DrReg" EventName="SelectedIndexChanged" />

   <asp:AsyncPostBackTrigger ControlID="Drcity" EventName="SelectedIndexChanged" />

   <asp:AsyncPostBackTrigger ControlID="DrZone" EventName="SelectedIndexChanged" />

  </Triggers>
                                <ContentTemplate>



                                <table style="width: 100%;" dir="rtl">
                                    <tr>
                                        <td>
                                           المنطقة
                                        </td>
                                        <td>
                                            <asp:DropDownList ID="DrReg" runat="server" AutoPostBack="True"  >
                                            </asp:DropDownList>
                                            <asp:ScriptManager ID="ScriptManager1" runat="server">
                                            </asp:ScriptManager>
                                        </td>

                                    </tr>
                                    <tr>
                                        <td>
                                           المدينة
                                        </td>
                                        <td>
                                            <asp:DropDownList ID="Drcity" runat="server"  AutoPostBack="True">
                                            </asp:DropDownList>
                                            <%-- <asp:ScriptManager ID="ScriptManager1" runat="server">
                                             </asp:ScriptManager>--%>
                                             <asp:SqlDataSource ID="OrgSQl" runat="server" 
                                                 ConnectionString="<%$ ConnectionStrings:ymConnectionString %>" 
                                                 SelectCommand="SELECT [GovID], [Gov_Title] FROM [Gov] WHERE (([Region_Id] = @Region_Id) AND ([FalgeDel] = @FalgeDel))">
                                                 <SelectParameters>
                                                     <asp:ControlParameter ControlID="DrReg" Name="Region_Id" 
                                                         PropertyName="SelectedValue" Type="Int32" />
                                                     <asp:Parameter DefaultValue="False" Name="FalgeDel" Type="Boolean" />
                                                 </SelectParameters>
                                             </asp:SqlDataSource>
                                        </td>

                                    </tr>
                                    <tr>
                                        <td>
                                          الحي
                                        </td>
                                        <td>
                                             <asp:DropDownList ID="DrZone" class="inputbox multiple" runat="server" AppendDataBoundItems="True" 
                                                 Width="120px">
                                                 <asp:ListItem Value="0">الكل</asp:ListItem>
                                            </asp:DropDownList> 

                                             <asp:SqlDataSource ID="Zonsql" runat="server" 
                                                 ConnectionString="<%$ ConnectionStrings:ymConnectionString %>" 
                                                 SelectCommand="SELECT * FROM [Zone] WHERE (([City_ID] = @City_ID) AND ([FlagDel] = @FlagDel))">
                                                 <SelectParameters>
                                                     <asp:ControlParameter ControlID="Drcity" Name="City_ID" 
                                                         PropertyName="SelectedValue" Type="Int32" />
                                                     <asp:Parameter DefaultValue="False" Name="FlagDel" Type="Boolean" />
                                                 </SelectParameters>
                                             </asp:SqlDataSource>
                                        </td>

                                    </tr>

                                     <tr>
                                        <td>

                                        </td>
                                        <td align="center">


                                                          <asp:LinkButton ID="SearchBtnok" class="button" runat="server" 
                                                              ValidationGroup="searchysf">ابحث</asp:LinkButton>
                                        </td>

                                    </tr>


                                </table>
                                  </ContentTemplate>


                                </asp:UpdatePanel>

代码是

Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
        ' btnCloseBrowser.Attributes.Add("onclick", "self.close()")

        If Not Page.IsPostBack Then

            obj.Bind(Me.DrReg, " countrt where FlageDel=0 ", "ALL")
            obj.Bind(Me.Drcity, " city WHERE FalgeDel=0 and Country_Id=" & DrReg.SelectedValue, "All")
            obj.Bind(Me.DrZone, " Zone WHERE FlagDel=0 and  City_ID =" & Drcity.SelectedValue, "اختر")

        End If



    End Sub



Protected Sub DrReg_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DrReg.SelectedIndexChanged


        obj.Bind(Me.Drcity, " city WHERE FalgeDel=0 and Country_Id=" & DrReg.SelectedValue, "All")
        obj.Bind(Me.DrZone, " Zone WHERE FlagDel=0 and  City_ID =" & Drcity.SelectedValue, "All")

    End Sub



Protected Sub Drcity_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Drcity.SelectedIndexChanged
        obj.begintrans()

        obj.Bind(Me.DrZone, " Zone WHERE FlagDel=0 and  City_ID =" & Drcity.SelectedValue, "All")
        obj.comitttrans()
    End Sub

1 个答案:

答案 0 :(得分:0)

您必须在每个下拉列表中设置AutoPostback="True"。触发器部分不会使它们回发,它只处理已经发生的事件。