Click here to Skip to main content
15,898,134 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi,

I have a dropdown which gets filled from databse . this is actually a filter.
on selected index change of this drop down i am showing data in gridview which is related to that id of selected index.

But now what i want to do is i want to display only those categories in dropdowns which are surely give me the data .. There should not be else part in selected index changed .. if nothing found related to selected dropdown id then "No data available". I want 100 persent sure categories from databse ..


How can i do that plz suggest .
Posted

1 solution

Torakami wrote:
But now what i want to do is i want to display only those categories in dropdowns which are surely give me the data
It's not a big deal. Just load the data which matches the details table data.
For example, you have two tables Country & City.
------------------------------
Country
------------------------------
CountryID | CountryName
------------------------------
1         | US
2         | UK
3         | Canada
------------------------------
City
------------------------------
CountryID CityID | CityName
------------------------------
1        |1      | New york
1        |2      | Los Angles
2        |1      | London
2        |2      | Luton
------------------------------

Now you have to write a query to load Available Countries(for Dropdown) like below
SQL
SELECT B.CountryID,A.CountryName FROM Country A, City B
WHERE A.CountryID=B.CountryID
Now it'll load only Countries which has cities.
------------------------------
Available Countries
------------------------------
CountryID | CountryName
------------------------------
1         | US
2         | UK
------------------------------

That's it.
 
Share this answer
 
Comments
Torakami 24-Oct-13 3:47am    
Thanks .. Logics works for me.
thatraja 24-Oct-13 4:53am    
welcome

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900