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
[quoted text, click to view] >-----Original Message-----
>I have a few DropDownLists, ListBoxs, and CheckBoxLists
and assume for
>the sake of argument that I want to put the same data in
all of these.
>Is there a way that I can just pass the name of the
controls and
>populate them in a common method.
>
>
>
>*** Sent via Developersdex
http://www.developersdex.com ***
>Don't just participate in USENET...get rewarded for it!
>.