0

I'm struggling with the design aspect of building this web site, its my first website and I'm not sure of the correct direction i need to take this project in. I've posted on this previously but not done a good job of explaining it. So I'll attempt to do so now.

The Site will be used for submitting "Innovation Ideas" from employees. It will have to connect up to an already existing MS Access Database. There will be two tables in this database that it has to communicate with.

The first one Is the InnovationSubmission Table which which looks similar to this :-

    ID(Auto Generated),
    Short Description,
    Long Description,
    Name,
    Email Address,
    Date(From Date.Time.Now()) - on Submission.
    Team Name
    Area (Area of Business)

The User will use a Web Form(View) to enter the details above, it will be validated, then saved to the back end database. I have this working in a fashion. The issue has started when I have tried to introduce two DropDownlistsFor contorls based on another table which is below :-

    AREA A - Team1, Team3, Team5, Team7
    AREA B - Team2, Team4, Team6, Team8

This is just sample Data, there are only two different areas in the table, but there will be over 50 teams split across them. I will be looking to have the Teams dropdownList filter on the value in the Area DropDownlist.

In my Models folder I have created a InnovationSubmission Class, that replicates the table in the database, this class is used as a strongly typed data type in the View representing the Submission Form. Its how i Validate the User input and I pass this class to a c# method that sends the data back using ADO.NET.

I'm struggling with how I should be trying to implement the dropdownlists.

Will I need to create a class similar to the InnovationSubmission Class, to represent the Teams/ Area Table? Is the table at present structured in the best way for this project? Can I populate both dropdownlists from the 1 table? How do I relate the Teams & Area Columns?

Any Help would be greatly appreciated!?!

Would this be the correct way to design my View Model :-

public class MyViewModel
    {
        public int ID { get; set; }
        public string shortDesc { get; set; }
        public string longDesc { get; set; }
        public string Status { get; set; }
        public string originator { get; set; }
        public string originatorEmail { get; set; }
        public IEnumerable<Area> area { get; set; }
        public IEnumerable<Team> team { get; set; }
    }

    public class Team
    {
        public string teamName { get; set; }
    }

    public class Area
    {
        public string area { get; set; }
    }
Derek
  • 8,300
  • 12
  • 56
  • 88

1 Answers1

1

You seem to be talking about cascading dropdown lists where the values of the second one update based on the selection made in the first one. I have illustrated an example of how this could be achieved in this post. The idea is that you subscribe to the .change event of the first dropdownlist and then trigger an AJAX request to a controller action passing the selected value in which you wold query the database and return a list of possible options.

Community
  • 1
  • 1
Darin Dimitrov
  • 1,023,142
  • 271
  • 3,287
  • 2,928
  • Thanks for this, it looks pretty much what I am trying to do. I have never done anything with AJAX, this should be fun! :-) – Derek Jul 04 '12 at 08:31