Step 1) Create ASP.NET EMPTY WEB APPLICTAION
STEP 2) ADD NEW PAGE CALLED DEFAULT.ASPX
STEP3) DRAG & DROP GRIDVIEW AS SHOWN BELOW
<body>
<form id="form1" runat="server">
<div>
<asp:gridview ID="Gridview1" runat="server"></asp:gridview>
</div>
</form>
</body>
public class Person
{
private String FullName;
private int Age ;
private float weight;
private float height;
private String Color;
public String FULLNAME
{
get { return FullName; }
set { FullName=value; }
}
public int AGE
{
get { return Age; }
set { Age = value; }
}
public float WEIGHT
{
get { return weight; }
set { weight = value; }
}
public float HEIGHT
{
get { return height; }
set { height = value; }
}
public String COLOR
{
get { return Color; }
set { Color = value; }
}
List<Person> perList = new List<Person>();
in Page_Load()
{
//Add sample data to List
perList.Add(new Person { FULLNAME = "Sitapati", AGE = 38, WEIGHT = 70, HEIGHT = 155, COLOR = "Black" });
perList.Add(new Person { FULLNAME = "shyam", AGE = 21, WEIGHT = 70, HEIGHT = 165, COLOR = "white" });
perList.Add(new Person { FULLNAME = "pari", AGE = 23, WEIGHT = 70, HEIGHT = 100, COLOR = "Black" });
perList.Add(new Person { FULLNAME = "pullela", AGE = 22, WEIGHT = 70, HEIGHT = 125, COLOR = "medium" });
//Bind to GridView
Gridview1.DataSource = perList;
Gridview1.DataBind();
}
STEP 2) ADD NEW PAGE CALLED DEFAULT.ASPX
STEP3) DRAG & DROP GRIDVIEW AS SHOWN BELOW
<body>
<form id="form1" runat="server">
<div>
<asp:gridview ID="Gridview1" runat="server"></asp:gridview>
</div>
</form>
</body>
STEP 4) Add new class called "Person.cs"
public class Person
{
private String FullName;
private int Age ;
private float weight;
private float height;
private String Color;
public String FULLNAME
{
get { return FullName; }
set { FullName=value; }
}
public int AGE
{
get { return Age; }
set { Age = value; }
}
public float WEIGHT
{
get { return weight; }
set { weight = value; }
}
public float HEIGHT
{
get { return height; }
set { height = value; }
}
public String COLOR
{
get { return Color; }
set { Color = value; }
}
Step 5) in Default.aspx.cs
//decalare list of Persons
List<Person> perList = new List<Person>();
in Page_Load()
{
//Add sample data to List
perList.Add(new Person { FULLNAME = "Sitapati", AGE = 38, WEIGHT = 70, HEIGHT = 155, COLOR = "Black" });
perList.Add(new Person { FULLNAME = "shyam", AGE = 21, WEIGHT = 70, HEIGHT = 165, COLOR = "white" });
perList.Add(new Person { FULLNAME = "pari", AGE = 23, WEIGHT = 70, HEIGHT = 100, COLOR = "Black" });
perList.Add(new Person { FULLNAME = "pullela", AGE = 22, WEIGHT = 70, HEIGHT = 125, COLOR = "medium" });
//Bind to GridView
Gridview1.DataSource = perList;
Gridview1.DataBind();
}
No comments:
Post a Comment