This is a migrated thread and some comments may be shown as answers.

AutoComplete to another control

2 Answers 66 Views
AutoCompleteBox
This is a migrated thread and some comments may be shown as answers.
David
Top achievements
Rank 1
David asked on 29 Jul 2013, 04:26 PM


Private
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"
 
      Master.Menubar.Add(radAutoBox)
<asp:SqlDataSource runat="server" ID="sqlDS" ConnectionString="<%$ ConnectionStrings:DefaultSqlConnection%>" >
      <SelectParameters>
          <asp:Parameter DbType="Int32" Name="userid"   />
          <asp:Parameter DbType="Int32" Name="divisionid"  />
          <asp:Parameter DbType="String" Name="SearchTerm" />
      </SelectParameters>       
  </asp:SqlDataSource>


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">
     <Columns>
         <asp:BoundField DataField="StockSizeGroupName" />
         <asp:BoundField DataField="StockSizeGroupID" />
         <asp:BoundField DataField="StockSizeName" />
     </Columns>
 </asp:GridView>

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


the BuildMenuBar Method is being called from the Page_Load Event

2 Answers, 1 is accepted

Sort by
0
Nencho
Telerik team
answered on 01 Aug 2013, 10:51 AM
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.

Regards,
Nencho
Telerik
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.
0
David
Top achievements
Rank 1
answered on 06 Aug 2013, 11:51 AM
thanks for the reply.
i decided to use the RadGrid instead which has a Filtering function. This has given me a similar functionality.

cheers
Tags
AutoCompleteBox
Asked by
David
Top achievements
Rank 1
Answers by
Nencho
Telerik team
David
Top achievements
Rank 1
Share this question
or