473,414 Members | 1,946 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,414 software developers and data experts.

Cannot use ListItems when inheriting from DropDownList

I am creating a control in which I inherit from the DropDownList. The only
method that I override is RenderContents. Here is my basic code:

Public Class StatesDropDownList : Inherits DropDownList

Protected Overrides Sub RenderContents(ByVal writer As
System.Web.UI.HtmlTextWriter)
'I add several items to the Items property here using Me.Items.Add()
MyBase.RenderContents(writer)
End Sub

End Class

However, when I attempt to add ListItems declaratively (by placing
<asp:ListItem/tags between the opening and closing tags for my control),
Visual Studio 2005 tells me "Element 'ListItem' is not a known element." I
am inheriting from DropDownList, and DropDownList works fine even in the
same Page, so shouldn't my control allow <asp:ListItem/tags as well? Any
help would be appreciated. Thanks.
--
Nathan Sokalski
nj********@hotmail.com
http://www.nathansokalski.com/
Oct 17 '08 #1
1 2532
Hi, Nathan.

You need to specify a ControlBuilder.

http://msdn.microsoft.com/en-us/libr...r(VS.85)..aspx

The ControlBuilder object must know how to create the items.

Regards,

Paulo Santos
http://pjondevelopment.50webs.com

On Oct 16, 9:36*pm, "Nathan Sokalski" <njsokal...@hotmail.comwrote:
I am creating a control in which I inherit from the DropDownList. The only
method that I override is RenderContents. Here is my basic code:

Public Class StatesDropDownList : Inherits DropDownList

* Protected Overrides Sub RenderContents(ByVal writer As
System.Web.UI.HtmlTextWriter)
* *'I add several items to the Items property here using Me.Items.Add()
* *MyBase.RenderContents(writer)
* End Sub

End Class

However, when I attempt to add ListItems declaratively (by placing
<asp:ListItem/tags between the opening and closing tags for my control),
Visual Studio 2005 tells me "Element 'ListItem' is not a known element." I
am inheriting from DropDownList, and DropDownList works fine even in the
same Page, so shouldn't my control allow <asp:ListItem/tags as well? Any
help would be appreciated. Thanks.
--
Nathan Sokalski
njsokal...@hotmail.comhttp://www.nathansokalski.com/
Oct 17 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: DC Gringo | last post by:
I'm having such a problem with this DropDownList in a user control that is posting back and throwing an error: System.Web.HttpException: A DropDownList cannot have multiple items selected ...
7
by: Doug | last post by:
I want to display a drop-down list (System.Web.UI.WebControls.DropDownList) loaded with font names the user can select (Verdana, Garamond, etc)... got this far no problem. Now I'd like to have...
1
by: Jeff | last post by:
Hi - I'm creating a web control library (using VB.NET), and I'm trying to add a modified asp:dropdownlist control to it. How do I add asp:ListItems to the dropdownlist (within the web control...
1
by: HoustonFreeways | last post by:
I am populating a dropdownlist via a databind to a database. However, the text to be displayed can be very long, making the dropdownlist very wide. I need some way to reduce the width of the...
2
by: Arthur Dent | last post by:
Hi all, I have a control which i wrote which inherits the asp:dropdownlist control. Works great, all happy. If when using it i try to declaratively add some items, it complains that they are...
5
by: Andrew Robinson | last post by:
I am attempting to better automate a Pager Template within a GridView. I am succesfully skinning a Drop Down List withing my control (the DDL is added to my control). I correctly populate the item...
8
by: sudhaMurugesan | last post by:
Hi, Can anyone Help. I have two dropdownlist for qualification and degree. According to the qualification(eg.Diploma,UG,PG) degree gets binded in the dropdownlist. I have done this in...
25
by: sudhaMurugesan | last post by:
Hi ALL, I am binding ListItems to dropdownlist using js.But the selected value is not retained while save operation. Do I need to capture the selected Item in any hiddenfields ? plz tell me ...
0
by: Radu | last post by:
I have a global resource, Scorecards.resx. For stuff like <asp:CustomValidator id="validDate" Text="*" ErrorMessage= "<%$ Resources:Scorecards, String66 %>" Display="Dynamic"...
1
by: Nathan Sokalski | last post by:
I am creating a control in which I inherit from the DropDownList. The only method that I override is RenderContents. Here is my basic code: Public Class StatesDropDownList : Inherits DropDownList...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.