AutoComplete to another control

3 posts, 0 answers
  1. David
    David avatar
    38 posts
    Member since:
    May 2013

    Posted 29 Jul 2013 Link to this post

    Sub fetchAutoBoxItems(ByVal sender As Object, ByVal e As AutoCompleteBoxDataSourceSelectEventArgs)
          ' Dim source As SqlDataSource = DirectCast(e.DataSource, SqlDataSource)
          'Dim autoCompleteBox As RadAutoCompleteBox = DirectCast(sender, RadAutoCompleteBox)
          Dim filterstring As String = e.FilterString
          sqlDS.SelectCommandType = SqlDataSourceCommandType.StoredProcedure
          sqlDS.SelectCommand = "my_db.dbo.my_SP"
          sqlDS.SelectParameters("SearchTerm").DefaultValue = filterstring
      End Sub
      Private Sub BuildMenuBar()
          Dim radAutoBox = New RadAutoCompleteBox
          radAutoBox.InputType = RadAutoCompleteInputType.Text
          radAutoBox.TextSettings.SelectionMode = RadAutoCompleteSelectionMode.Single
          radAutoBox.ID = "radAutoBox"
          AddHandler radAutoBox.DataSourceSelect, AddressOf fetchAutoBoxItems
          radAutoBox.Filter = RadAutoCompleteFilter.StartsWith
          radAutoBox.DataSource = sqlDS
          sqlDS.SelectParameters("userid").DefaultValue = CStr(_securityContext.UserID)
          sqlDS.SelectParameters("divisionid").DefaultValue = CStr(_securityContext.DivisionId)
          radAutoBox.DataTextField = "StockSizeGroupName"
          radAutoBox.DataValueField = "StockSizeGroupID"
    <asp:SqlDataSource runat="server" ID="sqlDS" ConnectionString="<%$ ConnectionStrings:DefaultSqlConnection%>" >
              <asp:Parameter DbType="Int32" Name="userid"   />
              <asp:Parameter DbType="Int32" Name="divisionid"  />
              <asp:Parameter DbType="String" Name="SearchTerm" />

    I am able to get the AutoCompleteBox to work nicely with the above code, but what i wish to do, though, is have the AutoComplete List appear in a GridView/DataGrid instead of the dropdownlist of the AutoCompleteBox.
    Is this possible? I am unable to get my GridView to share the same SqlDataSource Control due to the GridView never showing so i'm sure its not binding properly.

    <asp:GridView ID="gvAutoBox" runat="server">
             <asp:BoundField DataField="StockSizeGroupName" />
             <asp:BoundField DataField="StockSizeGroupID" />
             <asp:BoundField DataField="StockSizeName" />

    'add the following two lines below the ' Master.Menubar.Add(radAutoBox)' line in the 'BuildMenuBar' method
            gvAutoBox.DataSource = sqlDS

    the BuildMenuBar Method is being called from the Page_Load Event
  2. Nencho
    Nencho avatar
    1663 posts

    Posted 01 Aug 2013 Link to this post

    Hello David,

    Please note that the RadAutoCompleteBox should have a constant access to its datasource, since the databing mechanism of the control relies on the typed in the input text. Therefore, please make sure that  the binding logic is NOT encapsulated in an if(!isPostBack) statement in the Page_Load. If the issue still persist, I would like to ask you to isolate the problem in a runnable sample and provide us with it, so we could inspect it locally and provide you with the proper solution.

    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
  3. David
    David avatar
    38 posts
    Member since:
    May 2013

    Posted 06 Aug 2013 Link to this post

    thanks for the reply.
    i decided to use the RadGrid instead which has a Filtering function. This has given me a similar functionality.

Back to Top