In this article, we are going to learn how to bind drop-down list using Tuple in ASP MVC.
Before that, we should know wha Tuple is and what is the usage of a tuple.
What is Tuple?
Tuple is a generic static class that was added to C# 4.0 and it can hold any amount of elements, and they can be any type we want. So using a tuple, we can return multiple values.One great use of tuple might be returning multiple values from a method. It provides an alternative to "ref" or "out" if you have a method that needs to return multiple new objects as part of its response.

A tuple allows you to combine multiple values of possibly different types into a single object without having to create a custom class. This can be useful if you want to write a method that for example returns three related values but you don't want to create a new class.
To know more about Tuple, please refer Here
Let's see the step by step process to implement Binding drop down using Tuple,
Step 1
Let's create a simple mvc project in Visual studio. To do -> go to Visual Studio -> select File -> New - > Project -> click-> a new dialog window will open
Select "web" in the left pane and select "ASP.NET Web Application" main window.Then give a name for your project and click ok. Here, I have named my project as "BindingDropDownUsingTuple".
Now, a new dialog window will appear again. In that, select MVC and click ok.
Please find the below images for your references.
Step 2
Once the project has been created, you can see more folders in the solution file.
Step 3
Next, let's create a simple class under models folders. Here, I have created a class and named it as "SchoolModels".
Here's the sample code for your reference.
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. namespace DropDownBindingUsingTuple.Models
  6. {
  7. public class Departments
  8. {
  9. public int DeptId { get; set; }
  10. public string DeptName { get; set; }
  11. }
  12. public class Students
  13. {
  14. public int StudentId { get; set; }
  15. public string StudentName { get; set; }
  16. }
  17. }
Explanation of View Model
Here, I have created two classes such as "Departments" and "Students". The Departments class is used to bind the Department drop-down list and Students class is used to bind the Students' drop-down list.
Step 4
Next, let's create a simple controller under Controllers folder. Here, I have created a simple controller and named it as "SchoolController".
Step 5
Let's create a "Departments" and "Students" list to bind it to the drop-down list. Just add the below code in your index method.
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.Web.Mvc;
  6. using DropDownBindingUsingTuble.Models;
  7. namespace DropDownBindingUsingTuble.Controllers
  8. {
  9. public class SchoolController : Controller
  10. {
  11. // GET: SchoolDetails
  12. public ActionResult Index()
  13. {
  14. List<Departments> DeptList = new List<Departments>(); //List of Departments
  15. List<Students> StudentList = new List<Students>(); // List of Students
  16. DeptList.Add(new Departments
  17. {
  18. DeptId=1,
  19. DeptName="BCA"
  20. }); //adding list to DeptList Object
  21. DeptList.Add(new Departments
  22. {
  23. DeptId = 2,
  24. DeptName = "BSC"
  25. });
  26. DeptList.Add(new Departments
  27. {
  28. DeptId = 3,
  29. DeptName = "MCA"
  30. });
  31. StudentList.Add(new Students
  32. {
  33. StudentId=1,
  34. StudentName="Ramesh"
  35. }); // adding list to StudentList Object
  36. StudentList.Add(new Students
  37. {
  38. StudentId = 2,
  39. StudentName = "Kannan"
  40. });
  41. StudentList.Add(new Students
  42. {
  43. StudentId = 3,
  44. StudentName = "Vimal"
  45. });
  46. List<SelectListItem> DeptListNew = new List<SelectListItem>(); // Creating SelectListItem List
  47. List<SelectListItem> StudentListNew = new List<SelectListItem>();
  48. DeptListNew = DeptList.Select(x => new SelectListItem
  49. {
  50. Text=x.DeptName,
  51. Value=x.DeptId.ToString()
  52. }).ToList(); //Binding DeptList to SelectListItem DeptListNew
  53. StudentListNew = StudentList.Select(x => new SelectListItem
  54. {
  55. Text = x.StudentName,
  56. Value = x.StudentId.ToString()
  57. }).ToList(); //Binding StudentList to SelectListItem StudentListNew
  58. var TubleList = Tuple.Create<List<SelectListItem>,List<SelectListItem>>(DeptListNew,StudentListNew); //creating Tuple and passing two select list item in that.
  59. return View(TubleList); //passing Tuple to view.
  60. }
  61. }
  62. }
Step 6
Next, let us create a simple View for our Index action result. To create a View, right-click Index action result -> Add View -> just click OK.
Please find the below image and code for your reference.


  1. @model Tuple<List<SelectListItem>,List<SelectListItem>>
  2. @{
  3. ViewBag.Title = "Index";
  4. }
  5. <h2>Index</h2>
  6. @Html.DropDownList("DeptValue",Model.Item1, "Select","") @*Getting Tuple first list using Model.Item1*@
  7. <br />
  8. <br />
  9. <br />
  10. @Html.DropDownList("StudValue", Model.Item2, "select", "") @*Getting Tuple second list using Model.Item2*@
Step 7
Run the application and see the expected result. Please find the sample result below.