C# Web User Control help

G

Guest

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
 
W

wmain

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)
 
G

Guest

is this possible with an enum list?

wmain said:
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)
 
S

Steve C. Orr [MCSD, MVP, CSM, ASP Insider]

No problem.
Here's some sample code that should do the trick:

public enum AppType: int
{
HTML,
Word,
Excel,
PowerPoint,
WordPerfect
}

//Manage the requested export type
private AppType m_AppType;
[Bindable(true), Category("Behavior")]
public AppType ExportType
{
get
{
return m_AppType;
}

set
{
m_AppType= value;
}
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top