In aspx
<asp:GridView ID="GridView1" AutoGenerateColumns="true" DataSourceID="ObjectDataSource1" runat="server"> </asp:GridView> <asp:ObjectDataSource ID="ObjectDataSource1" SelectMethod="GetCustomers" TypeName="MyNamespace.CustomerManager" runat="server"></asp:ObjectDataSource>
In .cs (inside App_Code)
namespace MyNamespace { public class Customer { public string Name { get; set; } } public class CustomerManager { public List<Customer> GetCustomers() { List<Customer> cust = new List<Customer>(); Customer c = new Customer(); c.Name = "sampleName"; cust.Add(c); return cust; } } }
After that, I was able to see client information in the GridView.
source share