簡體   English   中英

Asp.Net C#DropDownList選定的索引更改大約需要50到60秒

[英]Asp.Net C# DropDownList Selected Index Change Taking about 50 to 60 Sec

在使用asp.Net網絡表單時。 我意識到並收到很多抱怨。 dropdown selected Index需要花費大量時間來綁定另一個Drop on Selected Index Change所做的檢查非常簡單,但是沒有運氣。

 <div class="col-sm-4">
                    <div>
                        <asp:Label Text="Category *" ID="LabelCompanyCategory" runat="server"></asp:Label>
                    </div>
                    <div>
                        <telerik:RadComboBox ID="DropDownListCompanyCategory" runat="server"
                            AutoPostBack="true" AppendDataBoundItems="true"
                            Width="100%" CssClass="form-control" CausesValidation="False"
                            DataSourceID="SqlDataSourceCategory" DataTextField="catDescription" DataValueField="CatId"
                            OnSelectedIndexChanged="DropDownListCompanyCategory_SelectedIndexChanged"
                            EmptyMessage="Select Category">
                        </telerik:RadComboBox>
                        <asp:RequiredFieldValidator runat="server" ErrorMessage="please select a category" Display="Dynamic"
                            ControlToValidate="DropDownListCompanyCategory" ForeColor="Red" ID="rfv2"></asp:RequiredFieldValidator>
                        <asp:SqlDataSource ID="SqlDataSourceCategory" ConnectionString='<%$ ConnectionStrings:MainConnection %>' runat="server"
                            SelectCommand=" select CatId, Catdescription from dbo.category"></asp:SqlDataSource>
                    </div>
                </div>
                <div class="col-sm-4" runat="server" id="DivActivity" visible="false">
                    <div>
                        <asp:Label Text="Activity *" ID="LabelCompanyActivity" runat="server"></asp:Label>
                    </div>
                    <div>
                        <telerik:RadComboBox ID="DropDownListActivity" runat="server" CssClass="form-control" Width="100%"
                            AppendDataBoundItems="false" DataSourceID="SqlDataSourceActivity" EmptyMessage="Select Activity" CausesValidation="False"
                            DataTextField="activity" DataValueField="id">
                        </telerik:RadComboBox>
                        <asp:RequiredFieldValidator runat="server" ErrorMessage="please select a Activity"
                            ControlToValidate="DropDownListActivity" ForeColor="Red" Display="Dynamic" ID="RequiredFieldValidator1"></asp:RequiredFieldValidator>
                    </div>
                    <asp:SqlDataSource ID="SqlDataSourceActivity" ConnectionString='<%$ ConnectionStrings:MainConnection %>' runat="server"
                        SelectCommand="select activity, id from activity where catid=@CategoryId">
                        <SelectParameters>
                            <asp:ControlParameter ControlID="DropDownListCompanyCategory" PropertyName="SelectedValue"
                                DefaultValue="0" Name="CategoryId" />
                        </SelectParameters>
                    </asp:SqlDataSource>
                </div>

后端代碼:

 protected void DropDownListCompanyCategory_SelectedIndexChanged(object sender, EventArgs e)
{
    DivActivity.Visible = true;
    DropDownListActivity.DataBind();
}

Telerik組件的運行速度非常快,但是您必須對其進行適當的配置並使用RadAjaxManager。 請在此處遵循示例: http : //demos.telerik.com/aspnet-ajax/combobox/examples/functionality/multiplecomboboxes/defaultcs.aspx

如果數據集非常大並且性能仍然不夠好,則必須配置loadOnDemand或恢復到客戶端數據綁定。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM