<br />
public class MyObject<br />
{<br />
private int id;<br />
public int ID { get { return id; } set { id = value; } }<br />
<br />
private string name;<br />
public string Name { get { return name; } set { name = value; } }<br />
<br />
private bool flag;<br />
public bool Flag { get { return flag; } set { flag = value; } }<br />
<br />
public MyObject(int id, string name, bool flag)<br />
{<br />
ID = id;<br />
Name = name;<br />
Flag = flag;<br />
}<br />
}<br />
<br />
public partial class Demo : System.Web.UI.Page<br />
{<br />
protected void Page_Load(object sender, EventArgs e)<br />
{<br />
List<MyObject> myObjectList = new List<MyObject>();<br />
myObjectList.Add(new MyObject(1, "Imdadhusen", true));<br />
myObjectList.Add(new MyObject(2, "Sunasara", false));<br />
myObjectList.Add(new MyObject(1, "ASP.Net", true));<br />
myObjectList.Add(new MyObject(1, "C#", true));<br />
myObjectList.Add(new MyObject(1, "Java", false));<br />
myObjectList.Add(new MyObject(1, "JSP", false));<br />
myObjectList.Add(new MyObject(1, "JavaScript", true));<br />
<br />
bindListBox(myObjectList, ListBox1);<br />
}<br />
<br />
public void bindListBox(List<MyObject> objList, ListBox lst)<br />
{<br />
if (objList != null)<br />
{<br />
for (int i = 0; i < objList.Count; i++)<br />
{<br />
ListBox1.Items.Add(new ListItem(objList[i].Name, objList[i].ID.ToString()));<br />
if (lst.SelectionMode != ListSelectionMode.Single) ListBox1.Items[i].Selected = objList[i].Flag;<br />
}<br />
}<br />
}<br />
<br />
}<br />