In my Controller I have been setting
ViewData.Model = DBModel.Table.Take(1).Single();
Where DBModel is create by DBML file of Linq-to-SQL
And I can access the Value thro' ViewData.Eval("ColumnName"),
But If I create my own class
Class Test{
public string Col = "Testing ViewData";
}
Test objTest = new Test();
ViewData.Model = objTest;
Now If I try to get ViewData.Eval("Col") returns null.
Both I tried to store in ViewData.Model.
Whats the problem on this.
Your definition of Col is a field, not a property. ViewData.Eval() only works against properties.
The NerdDinner tutorial should give you a good feel for how this is all supposed to work. Eval is not generally used in ASP.NET MVC.
The ViewData section should be of particular interest to you.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With