In Data access layer I have method to retrieve all the table values. How can I return it into the controller in asp.net MVC. can anyone help me?
Thanks in advance.
public static Dataset GetMembers()
{
//sql steps to retrieve records and fill it in dataset
}
Controller code:
{
var members = class.GetMembers()
return View(members);
}
You’ll need to modify your
GetMembersmethod (or implement another one that returnsIEnumerable<YourType>. In this example (since you don’t provide any additional data), I’ll return a list ofMyType, which I’ll assume looks like:And then populate a
List<MyType>insideGetMembersThis is a basic example of how you could return IEnumerable (of which
List<T>implements) from your method.