Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
615
Understanding the MVC Helper Demo
posted

Hi there, sorry if this seems totally basic, but I'm having trouble understanding the MVC Helper demo of the Combo Box here:

http://www.igniteui.com/combo/aspnet-mvc-helper

Specifically, I have a question about the ComboData() method:

[ComboDataSourceAction]
[ActionName("employee-combo-data")]
public
ActionResult ComboData()
{

IEnumerable
<Employee> employees = RepositoryFactory.GetEmployeeRepository().Get();
return
View(employees);
}


Why does this return a View instead of simply returning the employees list? I tried doing this in one of my own projects, and the framework kept complaining
that there was no view named "xyz" (I had chosen a different name than ComboData()), which of course there wouldn't be because this method is just gathering up the list of things to put in the combo (right?).

Maybe it would help if I describe the way I understand the program flow.

1) View() method is called from some controller method.
2) When the @Infragistics() call is encountered within the view, the DataSource URL is called to retrieve the collection (perhaps GetComboData()).
3) GetComboData() provides the Data to be wired up into the combo box, and the view finishes rendering.

Does this sound accurate? Thanks for any advice you can offer me!

Parents
  • 20255
    Verified Answer
    Offline posted

    Hello,

     Thank you for contacting us!

     About your question "Why does this return a View instead of simply returning the employees list?": When return a View() this View contains not only the list, also it contains other data that is needed to the page to render correctly, for example it have references to some layouts and styles. This is in order to tell the page how to look at all.

     In general the View() contains packed data for the page to render properly.

    May I add, some people use another approach to return a View like: return View("Index", someList). This is use in order to tell that exactly Index page will be rendered.

     About your explanation how you understand the program flow, you are correct, also I want to suggest you the article above to see the.

     If you need further information do not hesitate to contact me.

Reply Children
No Data