Asp.Net c#下拉列表所选索引改变大约需要50到60秒

本文关键字:60秒 改变 Net 下拉列表 索引 Asp | 更新日期: 2023-09-27 18:18:13

净webforms。我意识到并得到了许多抱怨。下拉选择的索引需要大量的时间来绑定另一个下拉选择的索引更改做了非常简单的事情,但没有运气。

 <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();
}

Asp.Net c#下拉列表所选索引改变大约需要50到60秒

teleerik Components非常快,但是您必须适当地配置它们并使用RadAjaxManager。请看下面的例子:http://demos.telerik.com/aspnet-ajax/combobox/examples/functionality/multiplecomboboxes/defaultcs.aspx

如果数据集非常大,性能仍然不够好,你必须配置loadOnDemand或恢复到客户端数据绑定