I agree with Kishor that your db needs a subtle change, but I totally disagree with him on the reasoning and method.
Your data is not normalized and that is one of your issues. I would suggest removing the state_id from the university table for starters. That column's presence only serves as a maintenance nightmare because anytime you update the city for a university, you'll have to update state as well along with an extra validation against the city-state relationship to ensure your data integrity. By removing the state_id field from the university table, you remove this entire issue. Your tables should look something like this:
[State](
[ID] [int] IDENTITY(1,1) NOT NULL,
[Name] [nvarchar](50) NOT NULL )
[City](
[ID] [int] IDENTITY(1,1) NOT NULL,
[Name] [nvarchar](50) NOT NULL ),
[StateID] [int] FK to [State].[ID]
[University](
[ID] [int] IDENTITY(1,1) NOT NULL,
[Name] [nvarchar](50) NOT NULL ),
[CityID] [int] FK to [City].[ID] )
Because you want to cascade update DropDownList controls on your WebForm, you may want to revisit how you are approaching this as well.
You could do it by just doing a complete postback like you are trying right now, but that is extremely inefficient as it causes the entire form to postback to the server and then the entire page has to be rerendered and sent back in the Response. What you are missing in this approach is that the page must be treated as a brand new page every time you receive a request. For example, if the user has selected the State and you want to populate Cities, you will have to populate both State and Cities and then also set the selected item of State as well before posting back. It may not sound like much, but the amount of data and hits to the database that you are going to have to make will be a huge performance nightmare.
A better approach is to implement an ajax or ajax/jquery generic handler to your form so that you can request just what you are looking for.
Here are some articles on how to approach it this way:
-
ASP.NET Advanced Generic Handler ASHX[
^]
-
jQuery AJAX and HttpHandlers in ASP.NET[
^]
-
AJAX: The Easy Way In ASP.NET WebForms Using Genric Handlers[
^]