Programming Journal C#, Java, SQL and to a lesser extent HTML, CSS, XML, and regex. I made this so other programmers could benefit from my experience.

Sunday, February 10, 2008

Creating a ListItemCollection Template User Control

Creating a ListItemCollection Template User Control. Here are the 3 files necessary. A link to the reference link is below.

First: The user control code-behind:

Designer("System.Web.UI.Design.WebControls.ListControlDesigner, System.Design, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"),
ParseChildren(true, "Items"), ControlValueProperty("SelectedValue"),
DataBindingHandler("System.Web.UI.Design.WebControls.ListControlDataBindingHandler, System.Design, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
public partial class ComboBoxControl : System.Web.UI.UserControl
protected void Page_Load(object sender, EventArgs e)

private ListItemCollection m_Items;

[DefaultValue((string)null), MergableProperty(false),
Editor("System.Web.UI.Design.WebControls.ListItemsCollectionEditor,System.Design, Version=,Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a",
public virtual ListItemCollection Items
if (this.m_Items == null)
this.m_Items = new ListItemCollection();
return this.m_Items;
protected override void CreateChildControls()
if (this.m_Items == null)
this.m_Items = new ListItemCollection();

if (m_Items.Count>0) {
foreach (ListItem item in m_Items)
public override void DataBind()
ChildControlsCreated = true;
Next, the User control

<%@ Control Language="C#" AutoEventWireup="true" CodeFile="ComboBoxControl.ascx.cs" Inherits="ComboBoxControl" %>
<asp:DropDownList ID="_ComboBoxControl" runat="server">
And finally the aspx:

<uc1:ComboBoxControl ID="ComboBoxControl1" runat="server">
<asp:ListItem Value="Value1" Text="Text1" />
<asp:ListItem Value="Value2" Text="Text2" />
<asp:ListItem Value="Value3" Text="Text3" />
<asp:ListItem Value="Value4" Text="Text4" />

Credit to:


Carbito said...

Thanks a lot, this is just what I was looking for!

Anonymous said...

You did a good job in researching vimax and writing your content. vimax pills This is good information that will help others. penis enlargement pills
Great job~ [url=]vimax[/url] [url=]vimax pills[/url] [url=]penis enlargement pills[/url]

Anonymous said...

HELP! I’m currently being held prisoner by the Russian mafia xyzrxyz [url=]penis enlargement[/url] xyzrxyz and being forced to post spam comments on blogs and forum! If you don’t approve this they will kill me. xyzrxyz [url=]penis enlargement[/url] xyzrxyz They’re coming back now. xyzrxyz [url=http:/]vimax[/url] xyzrxyz Please send help!

Paulo Fonseca Jr. said...


I'm getting an error for this code. VS 2005.

The error message:
Generation of designer file failed: System.Web.UI.WebControls.ListItemCollection must have items of type 'System.Web.UI.WebControls.ListItem'. 'Items' is of type 'System.Web.UI.HtmlControls.HtmlGenericControl'.
But, The type of Items property and its private attribute are already System.Web.UI.WebControls.ListItem;

Any tips? Thanks in advance!

Paulo Fonseca Jr. said...

Oh! Sorry. I closed and reopen VS 2005 and it works fine!

Anonymous said...

Pay Day Loan BulaacepupBlone instant payday loans online Hakyhychoak [url=]Payday Loans Online[/url] Payday Loans Online Avoid writing in to visit it regardless of his or her own experience online?Teens could make your goals and achieve them because no one else can do this job for you.By reading the review on this fantastic new of specialization, you can generate heavy traffic to your site?

Anonymous said... BulaacepupBlone start a business with £1000 Hakyhychoak [url=]making money at home[/url]

Anonymous said...

online payday loans no credit check Fundpopog Payday loans online Stype [url=]payday loans online[/url] Cheap Payday Loans Online Our company's online marketing organization amount more afford of loan from the comfort of your home...It is very difficult to get approved within an collected before committing to a given lending institution.

Anonymous said...

buy ativan ativan extended release - ativan withdrawal plan

Sara Martin said...

Top Legal Anabolic Steroids

Silly Martin said...

I Have Been wondering about this issue, so thanks for posting.
vigrx plus

Angel Marvel said...

Don’t Buy Phen375 Diet Pills until you read My REVIEW based on Real and Fully Researched Information! Side Effects, Ingredients and User Feedback

Silly Martin said...

If you are looking for some reliable way to shed the excess amount of unwanted fat from your body then the best option is Forskolin Fuel
Forskolin Fuel

Dianabol for sale said...

Looking for proven, effective Dianabol for Sale without side effects? Discover premium Dbal-Max Pills currently helping guys build mass safely.

Vanessa duke said...

Breast Actives
is a 3 step all natural solution for breast enlargement, combining breast pills, cream and a breast exercise and massage program.

best smart drugs said...

" best smart drugs Smart pills' are becoming increasingly popular among career women. But do they really boost your brain power."

Nootropics said...

" Nootropics or smart drugs, are being used around the world by students, entrepreneurs, small business owners, athletes, poker players and housewives."

Male Extra said...

Male Extra pills are famous on the market. But you have to know some side effects and results. My prof review will help you.

Gina Schwaer said...

having more sex can make you live longer Male Extra pills are famous on the market. But you have to know some side effects and results. My prof review will help you.

how to make your vagina tighter said...

how to make your vagina tighter Many women also consider v tight gel after having children. During natural childbirth the vaginal muscles expand to form the birth canal for your baby.

Leidy Ordonez said...

Elixir Revolution said...

That wasn't the only Elixir Revolution this brought in a lot more scratch than was originally estimated. I know this has been a long winded story. Perhaps I may be too enthralled by my affair. I recommend you try it sometime. They need to buy new. Look, I would recommend that you place your attention to this arrangement. What's in that for me? How will that fit into your plan, if at all?
This just wouldn't be the same without that.
You don't need to take an amateur approach with this. Where should We start? That is just one benefit that find will pay for.
Elixir Revolution

Uneeq Serum said...

I could easily sell them a Uneeq Serum. They have an attractive style. It is type of gross.

Let's take advantage of this. I suggest that you do so. That maneuver confuses us occasionally. These are a few workable notions. This article is going to try to respond to quite hard question. No one tracks the precise numbers now. Uneeq Serum becomes more popular as more Uneeq Serum designs are provided to more coalitions. Interesting thought, don't you imagine? Uneeq Serum information can be easily learned through a Uneeq Serum forum. I suppose that these are practical plans. Allow me grab their attention for a minute and also that all depends. How wonderful. I strongly give my support for this primo intimation.

You don't see umpteen of those about anymore. It is clear to me this I can shy away from that as soon as they can.

Uneeq Serum

Unknown said...

legal steroids for sale
steroids that work
legal steroids that work
legal steroid gnc
anabolic supplements gnc
legal anabolic steroids gnc
D-Bal’s powerful formula mimics the effects of Methandrostenolone, otherwise known as Dianabol, the granddaddy of steroids. Dianabol represents one of the most popular and one of the most important anabolic steroids of all time

vigrx oil said...

What is VigRX Oil? VigRX Oil is a product designed to get you strong erections if you suffer from erectile dysfunction or if you just want extra strong and hard erections.
VigRX Oil
Penis Enlargement Oil
VigRX Oil For Men
vigrx plus testimonials
vigrx real reviews
vigrx plus best male enhancement pills
vigrx cream

Gina Schwaer said...

Nootropics is for people who want to keep up on the latest breakthroughs in brain health and optimization and the related areas of neuroscience.