.Net GridView: Using LINQ and List as DataSource

Categories: .Net June 25th, 2014 23:52

Requirement:  create a GridView using LINQ and List;

image

Code:

Set DataSource:

GridViewUsers.DataSource = userManager.GetDataSource();
GridViewUsers.DataBind();

UserManager:

private List<User> users = new List<User>();

public List<User> GetDataSource() {
     var query =
         from user in users
         select user;
     return query.ToList();
}

<->



// Proudly powered by Apache, PHP, MySQL, WordPress, Bootstrap, etc,.