473,396 Members | 1,815 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

DropDownList question

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


Nov 18 '05 #1
3 988
Jos
Rafi wrote:
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

--

Jos
Nov 18 '05 #2

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

--

Jos


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

Nov 18 '05 #3
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
Nov 18 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Newbie | last post by:
I have a C# asp.net webform that contains a dropdownlist and a button that allows the user to select another item in the dropdownlist. The webform should work as follows: When the user selects...
2
by: Dominic | last post by:
Hi guys, I'm not sure if this question belongs to FAQ, but I couldn't find a concrete answer. I created a Datagrid control using ItemTemplate, but it's NOT a in-place editing datagrid. One of...
1
by: | last post by:
This is a crosspost from a less-frequented (but more focused) asp.net group; I didn't receive an answer that worked. I'd like to get this form functional. Could someone help on what's probably a...
3
by: Tim::.. | last post by:
Can someone please tell me how I go about preselecting an item in a drop drown list when I click the Edit Command in a datagrid? I have tried the following but it doesn't work for me! I would...
6
by: Julius Fenata | last post by:
Dear all, I have created client-side scripting to trigger event onChange from code-behind, like this: DropDownList1.Attributes = "GenerateArticleID()"; At the script on Windows Form, I...
1
by: Phil | last post by:
I would like to make the CreateUserWizard's security question box display as a databound (xml file) dropdownlist. I can make the dropdownlist display by using a contenettemplate, but I can't get...
0
by: Juanjo | last post by:
Hi, Before, I was working with Asp.net 1.0 and datagrid. I posted a question for this issue. The solution of this problem is load the second dropdownlist on the selectedindexchanged event of the...
4
by: glenn | last post by:
Hi folks, I am getting an error "Object reference not set to an instance of an object". It seems I have everything in place but something is obviously in err. If you could take a quick peak...
1
by: DJ | last post by:
I have a DropDownList in Visual Web Developer that is databound to a SQL Database. Whenever the web page is opened the DropDownList is automatically filled with the first item in the table. My...
6
by: shashi shekhar singh | last post by:
Respected Sir, I have to create multiple dynamic dropdownlist boxes and add items dynamically in <asp:table> server control but problem occurs , i.e. except of fist dropdown list no dropdownlist...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.