On Apr 9, 11:18 am, rodchar <rodc...@discussions.microsoft.comwrote:
hey all,
I have web user control (c# code-behind) and i'm trying to create a property
that will provide the user with a drop down list of values inside the
property box for that web user control instance and I'm having trouble with
the syntax, can someone please help me?
thanks,
rodchar
Lets say the user control contains a ListBox or a DropDownList. Lets
also assume it's named lstValues. You can make this list available to
the form using the user control by providing a public property of the
lstValues Items property.
public ListitemsCollection Items
{
get { return lstValues.Items; }
}
This will expose the Items property to the form containing the user
control. You can now use the add method of this property to add items
to this list of items.
uc1.Items.add(mylistitem);
You can also iterate through it ...
foreach(ListItem li in ux1.Items)