473,836 Members | 1,586 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

In ASP.Net Show Favourite Cities on top in a Dropdown List bound to City Table

13 New Member
In ASP.Net, I have a Dropdown List bound to a City Table with City Id as Value & City names as Data Text field.
I want to Show a few Favourite Cities on top as well as in their correct place in the Dropdown List. Help!
Jun 20 '07 #1
7 1720
kenobewan
4,871 Recognized Expert Specialist
Have you tried doing this in sql?
Jun 20 '07 #2
dip_developer
648 Recognized Expert Contributor
Have you tried doing this in sql?
what is your criteria to make a city favourite???
I propose to give a Ranking to every city and store it in a field(say city_ranking) in your table

Now u can easily have your favourite city with a sql like

SELECT city_name FROM tblCity WHERE city_ranking>50
Jun 20 '07 #3
arti
13 New Member
what is your criteria to make a city favourite???
I propose to give a Ranking to every city and store it in a field(say city_ranking) in your table

Now u can easily have your favourite city with a sql like

SELECT city_name FROM tblCity WHERE city_ranking>50
User will mark a few cities as favourites- which he might need frequently.
I want to show favourite city (ranking >10) on top of the list but the complete list should also appear below those cities.
I need the text & also Value- CityId of each ListItem. As I'll insert the CityId of the selected city in my Prospects Table. I want favourite cities on top as the user should not waste time in searching the list. The ranking can be changed when ever user wishes.
eg. Dropdown list should look like this:(Delhi has rank 1, Banglore 2 & Hyderabad 3). If I have to enter US,UK prospects, I'll mark NY, London as my favourites.

Delhi
Banglore
Hyderabad
----------
Alicante
Banglore
Barcelona
Basel
Buchrain Luzern
Dällikon
Delhi
Igualada
Hyderabad
Madrid
Shanghai
Jun 20 '07 #4
dip_developer
648 Recognized Expert Contributor
User will mark a few cities as favourites- which he might need frequently.
I want to show favourite city (ranking >10) on top of the list but the complete list should also appear below those cities.
I need the text & also Value- CityId of each ListItem. As I'll insert the CityId of the selected city in my Prospects Table. I want favourite cities on top as the user should not waste time in searching the list. The ranking can be changed when ever user wishes.
eg. Dropdown list should look like this:(Delhi has rank 1, Banglore 2 & Hyderabad 3). If I have to enter US,UK prospects, I'll mark NY, London as my favourites.

Delhi
Banglore
Hyderabad
----------
Alicante
Banglore
Barcelona
Basel
Buchrain Luzern
Dällikon
Delhi
Igualada
Hyderabad
Madrid
Shanghai
If you have a specific Raking system then you can just write the sql as

SELECT city_name,city_ id FROM tblCity ORDER BY city_ranking

this sql will give the desired result you want.You can use ASC(Ascending) and DESC(Descending ) clause with ORDER BY according to your Ranking system
Jun 21 '07 #5
arti
13 New Member
If you have a specific Raking system then you can just write the sql as

SELECT city_name,city_ id FROM tblCity ORDER BY city_ranking

this sql will give the desired result you want.You can use ASC(Ascending) and DESC(Descending ) clause with ORDER BY according to your Ranking system
Thanx a lot for your interest.
I would sort my list if I want Favourite entries on top only. But Pl note that those favourite cities are coming twice- once on top (then a separator) & second time in their normal place (Alphabetical order). And duplicate entries would not be allowed because of duplicate Data Value field. I have seen such lists in some website.
Delhi
Banglore
Hyderabad
----------
Alicante
Banglore
Barcelona
Basel
Buchrain Luzern
Dällikon
Delhi
Igualada
Hyderabad
Madrid
Shanghai
Jun 21 '07 #6
Plater
7,872 Recognized Expert Expert
I had to do something similar to this.
After you have binded the dropdown, do an insert at index positions to add them in.

So say you have a data object with all the items and a data object with all the favorite items. You would bind to the object with ALL the items, then itterate through the object with favorites, using the insert at index function to place them at the top.

I don't have VS on my computer right now so I can't provide source code, but hopefully that will be enough for you to find what you need.
Jun 21 '07 #7
arti
13 New Member
I had to do something similar to this.
After you have binded the dropdown, do an insert at index positions to add them in.

So say you have a data object with all the items and a data object with all the favorite items. You would bind to the object with ALL the items, then itterate through the object with favorites, using the insert at index function to place them at the top.

I don't have VS on my computer right now so I can't provide source code, but hopefully that will be enough for you to find what you need.
Thanks a lot! I had thought that if 2 listitems have same value (CityId) in a list, some problem would be there. But your idea is working!
Jun 22 '07 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

4
1987
by: Doslil | last post by:
I have a form which has a subform.In the main form I have only one field (this is a drop down list and has a query attached to it) which selects empno,Name from the EmployeeInformation table. The sub form stores the time sheet data for each employee.When I am able to do the timesheet data entry for the first record.But when I select the second employee from the dropdown list and click on the subform for entering the timesheet data, it...
2
1477
by: Marilee Haney via AccessMonster.com | last post by:
Hello! Here is my issue: I have a list of child care providers, their contact information, and stats in a table called tblproviders. I have clients request in another table. I want to match up clients with providers that meet their criteria and to bring up a list with the providers information on it. How would I go about doing this. In laymans terms preferably! :-) (not actual, just an idea)
0
1303
by: Pietje puk | last post by:
Hello, Since im quite new to ASP.NET i wanted to ask you folks what the best way is to create a WebForm for modifying 1 field from a record. The manipulation of this field can be done by using dropdown list. Previously i've written a lot of these page's by not using the webcontrols, but now i've reached this magically moment that i want to try these features. :D
7
3811
by: David Freeman | last post by:
Hi There! I'm trying to create a User Registration page in ASP.NET and wondering what is the best way to get the list of up-to-date Countries and Cities? Are there any Web Services on the web that I can use to retrieve such information? If not, what are the options? Please, any suggestions and pointers will be very much appreciated! Dave
1
1486
by: Mike C | last post by:
I'm new to Web development so I'm doing some bootstrapping and would really appreciate any help. Been grappling with this for days and am utterly confused by all the information on the web. I have a DataGrid with customer information. The last column is a dropdown template column that allows our reps to assign an attribute to the account i.e. small, medium, large or something like that. Here's where I'm stuck 1) I can't get the drop down...
2
2861
by: Peter | last post by:
ASP.NET 2003 In the DataGrid how do I select current cell value in the dropdown box when I click on the edit link, currently when I click on the edit link in the DataGrid the dropdown box appears in the cell, but allways the first item in the dropdown box is shown not the current cell value? How do I make the current value in the cell automaticaly be selected in the dropdown box.
6
3948
by: blouie | last post by:
Is there a way that a bound ddl control can: 1. display the bound data, even if it does not match a selection in the DDL? 2. allow the user to enter something other than the look up values? I have a bound dropdown list that retrieves it's selections from a look-up table. The DDL is bound to a database table and unless the value in the (text) field matches one of the look-up values, the page craps out.
2
2122
by: chandm | last post by:
i have one registration form in that registration state and city dropdownlists are there. when select Andhrapredesh in state(dropdownlist) then the related cities will be displayed in city(dropdownlist) how can we done this through javascript. please give me urgent
3
1274
by: sacha4 | last post by:
Hi, I am working on vb.net. I am really not able to find out how can i derive data from 3 dropdown box and show it in a text box. It's like this : My first dropdown shows States, second shows cities, and third shows counties. So the text box should be in this order: State/City/County. Can anyone please tell me how I can do that?
0
9825
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10859
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10560
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10260
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9388
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7795
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5653
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4463
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4023
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.