I have two dropdownlist one for project and 2nd for category.
I have a to select ddproject where i get id, based on this id i have to populate ddcategory.
Table Sturcture SQL FIDDLE
Here simple query if i select ProjectOne from my dropdownlist
select id,name from tbcategory where id in(1,2)
But my problem is i don’t know how many value will be there in the in condition.
C#:
1st i split column name categoryid and get values later what to do am confused.
Also let me know whether am doing in right way or any other alernative way to achive this
Edited:
Or should i change my table structure, if yes then what schema to be ?
According to your data, there is a many : many relationship between Category and Project. You therefore need to model another Many:Many table to hold data modelling this relationship.
SQL Fiddle Here
Firstly, create a new table to hold the Many:Many relationship between Category and Project:
Then, remove the string comma delimited relationship in tbProject – this isn’t useful. Instead, insert the links into the Many Many table. e.g.:
Will link project 1 to category 1 and 2.
Then, to find all the Categories for Project 1, you need to join through the Many:Many link table, filtering by the Project Id:
I’ve also removed your identity column for brevity’s sake – it makes it easier to know which data records are linked.