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.
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.
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- namespace DropDownBindingUsingTuple.Models
- {
- public class Departments
- {
- public int DeptId { get; set; }
- public string DeptName { get; set; }
- }
- public class Students
- {
- public int StudentId { get; set; }
- public string StudentName { get; set; }
- }
- }
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.


Dharmendra Kumar PanditPosted May 7, 2020, 12:31 PM
Nice article very helpfull.