1

My problem is that the selected index changed event of Obout Combobox doesn't fire at all.

See my code below :

      <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" />

Code behind

 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

I also have a function that loads items to the combobox

  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

I have seen a similar question in stack overflow but it doesnot have any answers.Also since I don't have aenough reputation I can't comment on it .

Please help.

Beldi Anouar
  • 2,170
  • 1
  • 12
  • 17
Linta Sheelkumar
  • 195
  • 1
  • 5
  • 21
  • Can you show where you add your handler to the SelectedIndexChanged event? You should have a combobox.SelectedIndexChanged += dbPractice_SelectedIndexChanged somewhere. – Tim Copenhaver Jun 15 '16 at 12:54
  • Im sorry I have not added any handler anywhere else.. – Linta Sheelkumar Jun 15 '16 at 13:44
  • can you think of any reason this event cannot get fired pls? – Linta Sheelkumar Jun 15 '16 at 14:20
  • This is what I get for jumping between threads - I was posting C# syntax, not VB.Net. The syntax you have is correct. Out of curiosity, how are you testing the event? Are you using the mouse or keyboard to change the selected item? – Tim Copenhaver Jun 15 '16 at 14:30
  • Oh that's fine..I'm using the mouse.. – Linta Sheelkumar Jun 15 '16 at 16:03
  • This is hard to answer given only the information here, but I can give you some more troubleshooting steps. Your event is on the server, but the control is on the client. In order to fire your event, there has to be some javascript in the page sending a request to the server. Check your browser debug tools - pay attention to the Console and Network windows while you change the selection. What do you see there? – Tim Copenhaver Jun 15 '16 at 16:59
  • Hi Tim, there is no javascript written for selected index changed event.Do I need to write anything? – Linta Sheelkumar Jun 16 '16 at 16:03
  • I have found the problem.Have posted the answer below..Many Thanks for your help with this. – Linta Sheelkumar Jun 28 '16 at 12:52

1 Answers1

0

Hi I have managed to make the Selected Index changed event work.

The only thing I did is in the aspx page I added AllowCustomText="true" instead of 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">

That has solved my problem!

Please note: If this value is set to false it will not give you the selected value.It will be always empty. So before saving Set AllowCustomText ppty to False and then save it!.

It is weird why that could be causing an issue but it worked!

Thanks for all your help!

Linta Sheelkumar
  • 195
  • 1
  • 5
  • 21