在asp.Net webforms上工作。我意识到并得到了很多抱怨。下拉选择索引正在花费大量时间绑定另一个选定索引更改下拉确实非常简单,但没有运气。
[Authorize(ActiveAuthenticationSchemes = "Bearer")]
后端代码:
<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>
答案 0 :(得分:0)
Telerik组件速度惊人,但您必须正确配置它们并使用RadAjaxManager。 按照这里的例子: http://demos.telerik.com/aspnet-ajax/combobox/examples/functionality/multiplecomboboxes/defaultcs.aspx
如果数据集非常大且性能仍然不够好,则必须配置loadOnDemand或恢复为客户端数据绑定。