Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.NET AJAX's Combobox - Cannot Programatically Change the Selected Item

Tags:

asp.net-ajax

I'm using the new Microsoft ASP.NET Ajax ComboBox control in my web application, and I'm having trouble figuring out how to programmatically set the selected list item. For example, I have a form to accept addresses and a ComboBox to accept a city name. After the user enters and saves and address, I'd like to reset the form, including the ComboBoxes.

With a regular ASP.NET dropdownlist control I can reset the selected item like below:

City.SelectedIndex = -1;

The ASP.NET AJAX ComboBox control accepts this line of code; but when the page posts back, the previously selected value is still selected. Help would be appreciated.

Update: I tried the following to no avail...

City.ClearSelection();
like image 330
jwalkerjr Avatar asked May 19 '09 04:05

jwalkerjr


1 Answers

One Solution for this is use Following 2 Commands Before you load page Second time or make it visible in update Panel

            Combobox1.ClearSelection()
            Combobox1.Dispose()

This will Clear Combobox Value.

Hope this Helps. Took me a while to find it.

like image 170
Bhushan Pachpande Avatar answered Sep 28 '22 06:09

Bhushan Pachpande