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

Update asp textbox value

3 Answers 159 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
Rajiv
Top achievements
Rank 1
Rajiv asked on 26 Feb 2009, 04:59 AM
Hello,
On my web page, I am having two Rad Combo boxes and a asp TextBox. On selecting the item from the first Radcombo box I am loading the data in the second Radcombo box. This is implemented as shown in the demos here:
http://demos.telerik.com/aspnet-ajax/combobox/examples/functionality/multiplecomboboxes/defaultcs.aspx

Now, my requirement is that on selecting an item from the second rad combo, I want the asp textbox to be populated with the value from the database. And this needs to be implemented without the page doing postback(i.e. using AJAX).

How should I implement this change. Please suggest.

Regards,
Rajiv

3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 26 Feb 2009, 07:31 AM
Hello Rajiv,

On the SelectedIndexChanged event of the second RadComboBox you can write select query to populate your textbox. The SelectedIndexChanged event  of the combobox will fire once you set the AutoPostBack property of it to true(shown below).
aspx:
<telerik:RadComboBox ID="RadComboBox2" AutoPostBack="true" runat="server" OnSelectedIndexChanged="RadComboBox2_SelectedIndexChanged"
</telerik:RadComboBox> 

cs:
  protected void RadComboBox2_SelectedIndexChanged(object o, RadComboBoxSelectedIndexChangedEventArgs e) 
    { 
        //query to select an item from the database 
        TextBox1.Text = strtxt;   
         
    } 

Inorder to avoid postback while populating your textbox you can use a RadAjaxManager for which the AjaxControlID should be set to the id of the second RadComboBox and the updated control should be set to the textbox. For more information on AjaxManager refer to the following link:
AJAX Manager

Thanks
Princy.               
0
Rajiv
Top achievements
Rank 1
answered on 28 Feb 2009, 04:30 AM
Thank you for the reply, Princy.

I made the changes suggested below and and was able to update the text box value. But intermittently I am getting the "The state information is invalid for this page and might be corrupted." error. This error occurs on click on the second RadComboBox .

Please help.

Regards,
Rajiv
0
Rajiv
Top achievements
Rank 1
answered on 28 Feb 2009, 10:52 AM
I was able to fix this problem, an unwanted postback was causing this error.
Thanks,
Rajiv
Tags
Ajax
Asked by
Rajiv
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Rajiv
Top achievements
Rank 1
Share this question
or