Tuesday, November 17, 2009

List Generic Controls

public class Product
{
public Product()
{
//
// TODO: Add constructor logic here
//
}
private int number;
public int Number
{
get { return number; }
}

private string name;
public string Name
{
get { return name; }
}

public Product(int number, string name)
{
this.name = name;
this.number = number;
}
}

===============================================
// List
List list = new List();
list.Add(new Product(1,"Murli"));
list.Add(new Product(2,"Sanjay"));
list.Add(new Product(3,"Mahesh"));
list.Add(new Product(4,"Tom"));


List intlist = new List();
intlist.Add(1);
intlist.Add(2);
intlist.Add(5);
intlist.Add(7);

for (int i = 0; i < intlist.Count; i++)
{
lblMessage.Text += "
No " + i + " :" + intlist[i];
}

foreach (int layland in intlist)
{
lblMessage.Text += layland;
}


GridView1.DataSource = intlist;
GridView1.DataBind();

No comments:

Post a Comment