473,399 Members | 2,478 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,399 software developers and data experts.

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

13
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 1700
kenobewan
4,871 Expert 4TB
Have you tried doing this in sql?
Jun 20 '07 #2
dip_developer
648 Expert 512MB
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
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 Expert 512MB
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
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 Expert 4TB
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
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
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. ...
2
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...
0
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...
7
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...
1
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...
2
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...
6
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...
2
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...
3
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...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...
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
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,...
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
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...

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.