Obout Combobox选择了Index change事件无法正常工作

时间:2016-06-15 12:46:12

标签: asp.net vb.net selectedindexchanged obout

我的问题是Obout Combobox的选定索引更改事件根本不会触发。

请参阅下面的代码:

      <obout:ComboBox ID="ddPractice" runat="server" Width="350" MenuWidth="650" Height="180"
                    DataTextField="LocationText" DataValueField="LocationID" EmptyText="Search By Practice Name/Code/PostCode"
                    EnableLoadOnDemand="true" EnableVirtualScrolling="true" AutoValidate="true"  AutoPostBack="true" AllowCustomText="false" 
                    TabIndex="11">

                    <HeaderTemplate>
                        <div class="header" style="width: 290px;">
                            Practice
                        </div>
                        <div class="header" style="margin-left: 0px; width: 90px;">
                            PostCode
                        </div>
                        <div class="header" style="margin-left: 0px; width: 90px;">
                            Practice Code
                        </div>
                        <div class="header" style="margin-left: 0px; width: 100px;">
                            PCT
                        </div>
                    </HeaderTemplate>
                    <ItemTemplate>
                        <div class="item" style="width: 290px;">
                            <%# Eval("LocationName")%>
                        </div>
                        <div class="item" style="margin-left: 0px; width: 90px;">
                            <%# Eval("PostCode")%>
                        </div>
                        <div class="item" style="margin-left: 0px; width: 90px;">
                            <%# Eval("PracticeCode")%>
                        </div>
                        <div class="item" style="margin-left: 0px; width: 100px;">
                            <%# Eval("PCTName")%>
                        </div>
                    </ItemTemplate>
                </obout:ComboBox>

                          <asp:TextBox ID="txtPractice"  runat="server" Width="250px" Height="21" Visible="false" />

背后的代码

 Private Sub ddPractice_SelectedIndexChanged(sender As Object, e As Obout.ComboBox.ComboBoxItemEventArgs) Handles ddPractice.SelectedIndexChanged
   If ddPractice.SelectedValue = "685" Then
       txtPractice.Visible = True
   End If
End Sub

我还有一个将项加载到组合框的功能

  Private Sub Practice_LoadingItems(sender As Object, e As     Obout.ComboBox.ComboBoxLoadingItemsEventArgs) Handles ddPractice.LoadingItems

    Dim data As DataTable = GetPractices(e.Text, e.ItemsOffset, 10)

    Dim combobox As Obout.ComboBox.ComboBox = CType(sender, Obout.ComboBox.ComboBox)
    combobox.DataSource = data
    combobox.Items.Clear()
    combobox.DataBind()

    e.ItemsLoadedCount = e.ItemsOffset + data.Rows.Count

    e.ItemsCount = GetPracticesCount(e.Text)
       End Sub

我在堆栈溢出中看到了类似的问题,但它没有任何答案。而且由于我没有足够的声誉,我无法评论它。

请帮忙。

1 个答案:

答案 0 :(得分:0)

您好我已经设法让选定的索引更改了活动。

我唯一做的是在aspx页面中我添加了AllowCustomText =“true”而不是false。

 <obout:ComboBox ID="ddPractice" runat="server" Width="350" MenuWidth="650" Height="180"
                    DataTextField="LocationText" DataValueField="LocationID" EmptyText="Search By Practice Name/Code/PostCode" AutoPostBack="true"
                    EnableLoadOnDemand="true" EnableVirtualScrolling="true" AutoValidate="true"  AllowCustomText="true" 
                    TabIndex="11" style="top: 0px; left: 0px">

这解决了我的问题!

请注意:如果此值设置为false,则不会为您提供所选值。它将始终为空。 所以在将Allow AllowCustomText ppty保存为False然后保存之前!。

奇怪的是,为什么这可能导致问题,但它有效!

感谢您的帮助!