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

Postbacks

2 Answers 140 Views
AutoCompleteBox
This is a migrated thread and some comments may be shown as answers.
Kim
Top achievements
Rank 1
Kim asked on 26 Jul 2013, 05:15 AM
I am new to the telerik controls so pardon my ignorance.

I have an AutoComplete box bound in code behind to an list.  

When the webform loads I set the data souce. When i type a letter into the autocomplete box the form posts backs. 

This is my  code:

        If Not IsPostBack Then
            RadAutoCompleteBox1.DataSource = App.Clients.Items.Values.ToArray
            RadAutoCompleteBox1.DataBind()
        End If

If I remove it from the if condition the box works but the page posts back every key press. Is this how its supposed to work?

If so my problem, is this. I have a radcombobox and when a user selects an item, using AJAX and client side, the datasource of the autocomplete changes based on the selection in the radcombo.

However when the user type a character the entire page posts back and i get the following error.

"The Control DataSource(or DataSourceID) is not set"

What i figured out is when the page posts back the autocomplete no longer has a binding and throws the error.

I had this working using two combo boxes but i wanted to us the autocomplete in place of the second combo.

Intuitively this does not work like i would think it should. am i doing something wrong here?



2 Answers, 1 is accepted

Sort by
0
Kim
Top achievements
Rank 1
answered on 26 Jul 2013, 05:23 AM


I guess my issue isn't the postback, but why do the combos remember their binding but the autocomplete does not. I would think they should work the same. As a rule i put my code in and "If IsPostBack" block or my chained combos get wiped out. 

0
Nencho
Telerik team
answered on 29 Jul 2013, 11:38 AM
Hello Kim,

The DataSource of the RadAutoCompleteBox should be supplied regardless if a PostBack occurs or not. The binding mechanism of the control, relies on the currently type character ( where a callback occurs ) upon which the control is populated. Each time a character is typed, a callback is initiated in order to performed the query to the used datasource. Here you could find our help article, demonstrating the data biding to a various datasources and here is our online demo on the matter.

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.
Tags
AutoCompleteBox
Asked by
Kim
Top achievements
Rank 1
Answers by
Kim
Top achievements
Rank 1
Nencho
Telerik team
Share this question
or