How to add List<> values to gridview?

Posted by ranadheer on Stack Overflow See other posts from Stack Overflow or by ranadheer
Published on 2012-03-21T05:25:47Z Indexed on 2012/03/21 5:30 UTC
Read the original article Hit count: 183

Filed under:
|

I created a asp.net website. and added a class file to it. i wrote this code in classfile.(person.cs)

public class Person
{
public string name{get; set;}
public int age { get; set; }
public float sal { get; set; }

public Person(string n, int a, float s)
{
    name = n;
    age = a;
    sal = s;
}


public List<Person> getDetails()
{
    Person p1 = new Person("John",21,10000);
    Person p2 = new Person("Smith",22,20000);
    Person p3 = new Person("Cena",23,30000);
    List<Person> li = new List<Person>();
    li.Add(p1);
    li.Add(p2);
    li.Add(p3);
    return li;
}

}

and i want this list to display in my gridview.

so, i have added a default page in website. then what should i write in default.aspx.cs file?so that my list values are shown on gridview?

Thanks.

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about gridview