Node is saved as draft in My Content >> Draft
-
View Data in MVC
View Data in MVC is used to transfer data from controller to view.
View Data is used to store objects in collection form.
View Data is used to access single value or collection of values from the controller to view.
View Data can be accessed in the View page using string as the key.
//Controller Code
public ActionResult Index()
{
List<string> Student = new List<string>();
Student.Add("Jignesh");
Student.Add("Tejas");
Student.Add("Rakesh");
ViewData["Student"] = Student;
return View();
}
//page code
<ul>
<% foreach (var student in ViewData["Student"] as List<string>)
{ %>
<li><%: student%></li>
<% } %>
</ul>
0 Comment(s)