CheckBoxList的更新一个下拉列表中的UpdatePanel不再回传

问题描述 投票:0回答:1

我需要根据一个CheckBoxList的选定值(S),避免了重新加载页面,我使用一个UpdatePanel更新Dropdowlist。该dropdwonlist应该始终有一个自动回发,它应该永远触发我的“SearchEvent”

我用我的CheckBoxList一个UpdatePanel和AsyncPostBackTrigger调用代码的功能背后刷新dropdowlist。

它的工作原理只有一次。第一个电话后,我不能触发的CheckBoxList的SelectedIndexChanged,而不是我的错误:

“Sys.WebForms.PageRequestManagerServerErrorException:在处理服务器上的请求时出现未知错误从服务器返回的状态码为:404”

我的下拉列表也失去了回传,没有任何反应。

查看ASPX:

<td>
<asp:ScriptManager ID="ScriptManager" runat="server" />
 <asp:CheckBoxList ID="IsActiveFilterCheck" runat="server" AutoPostBack="true" AppendDataBoundItems="true" CausesValidation="False">
            <asp:ListItem Text="Active" Value="1" />
            <asp:ListItem Text="Closed" Value="0" />
 </asp:CheckBoxList>
</td>
<td>
<asp:UpdatePanel ID="UpdatePanel1" ChildrenAsTriggers="true" UpdateMode="Conditional" runat="server">
     <Triggers>
         <asp:AsyncPostBackTrigger ControlID="IsActiveFilterCheck" EventName="SelectedIndexChanged" />
     </Triggers>
    <ContentTemplate>
        <br /><br />
        <asp:DropDownList ID="StatusFilterList" runat="server" DataTextField="Name" DataValueField="Id">
        </asp:DropDownList>
   </ContentTemplate>
</asp:UpdatePanel>
</td>

我后面的代码:

private void Page_Load(object sender, System.EventArgs e)
{
RegisterCallbacks();
if (!IsPostBack)
{
    Initialize();
     }
 }

 override protected void OnInit(EventArgs e)
{
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
CheckProfil();
InitializeComponent();
base.OnInit(e);
 }

private void InitializeComponent()
{
   this.SearchButton.ServerClick += new System.EventHandler(this.SearchButton_ServerClick);
   this.StatusFilterList.SelectedIndexChanged += new System.EventHandler(this.SearchButton_ServerClick);
   this.IsActiveFilterCheck.SelectedIndexChanged += new System.EventHandler(this.IsActiveFilterCheck_Changed);
   this.Load += new System.EventHandler(this.Page_Load);
}

protected void IsActiveFilterCheck_Changed(object sender, EventArgs e)
    {
        // Update the Status Filter List
        StatusFilterList.Items.Clear();
        if (IsActiveFilterCheck.Items.Cast<ListItem>().Where(li => li.Selected).ToList().Count != 1)
        {
            BindListInsertAll(StatusFilterList, ExpectedStatusCollection.Instance.GetAll());
        }
        else
        {
            IList statusSelected = ExpectedStatusCollection.Instance
                                                            .GetAll().Cast<ExpectedStatusDo>()
                                                            .Where(exp => IsActiveFilterCheck.SelectedValue == "1" ? exp.Id != 5 && exp.Id != 6 : exp.Id == 5 || exp.Id == 6)
                                                            .ToList(); // Only Dead and Signed
            // Update the Status
            BindListInsertAll(StatusFilterList, statusSelected);
        }

        UpdatePanel1.Update();
        //FindByFilter();
    }

当我改变IsActiveFilterCheck的CheckBoxList我应该只更新StatusFilterList如图IsActiveFilterCheck_Changed的功能,而无需重新加载整个页面。

这StatusFilterList应该总是能够调用/触发事件SearchButton_ServerClick

现在,它的工作原理,当IsActiveFilterCheck被激发我的dropdowlist被更新,但之后当我点击任何地方我的错误,我不能触发IsActiveFilterCheck只有一次

c# asp.net triggers updatepanel checkboxlist
1个回答
1
投票

看看这个:

AsyncPostBackTrigger works only the first time

人们通常再现了触发之后第一次上班。

© www.soinside.com 2019 - 2024. All rights reserved.