Hi
You can add items programmatically at run time to all
list Web server controls: ListBox, DropDownList,
CheckBoxList, and RadioButtonList.
You can add items to a list Web server control in these
ways:
To add items programmatically
Create a new object of type ListItem and set its Text and
Value properties.
Call the Add method of the control's Items collection and
pass it the new object.
The following example shows how to add ListItem objects
to a ListBox control, but the procedure is identical for
all list Web server controls.
' Visual Basic
Private Sub Button1_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles Button1.Click
Me.ListBox1.Items.Add(New ListItem("Carbon", "C"))
Me.ListBox1.Items.Add(New ListItem("Oxygen", "O"))
End Sub
// C#
public void Button1_Click (object sender,
System.EventArgs e)
{
this.ListBox1.Items.Add(new ListItem("Carbon", "C"));
this.ListBox1.Items.Add(new ListItem("Oxygen", "O"));
}
HTH
Ravikanth