【问题标题】:Obout Combobox selected Index changed event not workingObout Combobox selected Index changed 事件不起作用
【发布时间】:2016-06-15 12:46:12
【问题描述】:

我的问题是 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

我在堆栈溢出中看到了一个类似的问题,但它没有任何答案。另外,由于我没有足够的声誉,我无法对此发表评论。

请帮忙。

【问题讨论】:

  • 您能说明您将处理程序添加到 SelectedIndexChanged 事件的位置吗?您应该在某处有一个 combobox.SelectedIndexChanged += dbPractice_SelectedIndexChanged。
  • 对不起,我没有在其他任何地方添加任何处理程序..
  • 你能想出这个事件不能被触发的任何原因吗?
  • 这是我在线程之间跳转的结果——我发布的是 C# 语法,而不是 VB.Net。您拥有的语法是正确的。出于好奇,您如何测试该事件?你是用鼠标还是键盘来改变选中的项目?
  • 哦,那很好..我正在使用鼠标..

标签: asp.net vb.net selectedindexchanged obout


【解决方案1】:

您好,我已设法使 Selected Index changed 事件起作用。

我唯一做的就是在 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,则不会为您提供所选值。它将始终为空。 所以在保存之前 Set AllowCustomText ppty 为 False 然后保存!。

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

感谢您的帮助!

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-11-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多