DropDownList question

  • Thread starter Thread starter Rafi
  • Start date Start date
R

Rafi

Hi,

During Page_Load I DataBind() my DropDownList which shows alphabetical
list of cities stored in a table tbCities in my data base on Sql Server. On
the same page I can add a new city to the data base. How can I refresh my
DropDownList and show all cities in an alfabethical order?

The thing I was doing, I filled my dataAdapter with dataset, and binded my
DropDownList once more. The problem is, that the new city is shown in DDL at
the very bottom.

Rafi
 
Rafi said:
Hi,

During Page_Load I DataBind() my DropDownList which shows
alphabetical list of cities stored in a table tbCities in my data
base on Sql Server. On the same page I can add a new city to the data
base. How can I refresh my DropDownList and show all cities in an
alfabethical order?

The thing I was doing, I filled my dataAdapter with dataset, and
binded my DropDownList once more. The problem is, that the new city
is shown in DDL at the very bottom.

Rafi

Can it be that the table tbCities is already in alfabetical order?
In that case, to fill your list again, use an SQL statement such as:

SELECT * FROM tbCities ORDER BY city

instead of

SELECT * FROM tbCities
 
Can it be that the table tbCities is already in alfabetical order?
In that case, to fill your list again, use an SQL statement such as:

SELECT * FROM tbCities ORDER BY city

instead of

SELECT * FROM tbCities

Hi,

unfortunatelly this is not my problem. My tbCities is not in an alphabetical
order, so in my dataAdapter SelectCommand I have

SELECT * FROM tbCities ORDER BY city

when the page loads my DDL is in alphabetical order, but after uodate not:(

Rafi
 
Instead of binding to the data adapter create a dataView that is bound to
the adapter and then bind to you DDL to the dataview


Jim
 
Back
Top