您好,我有一个包含 CUSTOMERS 的组合框,然后是一个带有网格视图的更新面板,也包含 CUSTOMERS(与组合框相同)。用户从组合框中选择一个客户,然后 gridview 得到更新,组合框总是有所有的客户。我遇到的问题是更新面板仅在用户第一次选择客户时触发组合框 selectedindexchanged ,因此如果他们想更改客户,则不会发生任何事情。调试它根本不会触发。如果我将组合框放在更新面板中,它确实有效,但速度很慢。是否有任何替代组合框具有相同的搜索/下拉/自动完成功能?
如果您想查看,这是我当前的代码
<asp:ComboBox ID="cbCustomer" runat="server" AutoCompleteMode="SuggestAppend"
AutoPostBack="True" DataSourceID="dataSourceCBCust" DataTextField="CUST_NAME"
DataValueField="CUST_NO" MaxLength="0" style="display: inline;">
</asp:ComboBox>
<asp:UpdatePanel ID="upCustomer" runat="server" ChildrenAsTriggers="true" UpdateMode="Conditional">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="cbCustomer" EventName ="SelectedIndexChanged" />
<asp:AsyncPostBackTrigger ControlID="gvSiteAddress" EventName ="SelectedIndexChanged" />
</Triggers>
<ContentTemplate>
<br />
<asp:GridView ID="gvCustomer" runat="server" AllowPaging="True" DataSourceID="dataSourceGVCust"
AutoGenerateColumns="True" DataKeyNames="CUST_NO" Visible="False">
<Columns>
<asp:CommandField ShowSelectButton="True" />
</Columns>
<SelectedRowStyle BackColor="#CE5D5A" Font-Bold="True" ForeColor="White" />
</asp:GridView>
</ContentTemplate>
</asp:UpdatePanel>
后端
Protected Sub cbCustomer_SelectedIndexChanged(sender As Object, e As EventArgs) _
Handles cbCustomer.SelectedIndexChanged
dataSourceGVCust.SelectCommand = _
ConfigurationManager.AppSettings("SelectCustomer") _
& " WHERE CUST_NO LIKE '%" _
& cbCustomer.Text.TrimEnd _
& "%' ORDER BY CUST_NAME"
gvCustomer.Visible = True
End Sub