473,465 Members | 1,622 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

CheckBoxList and custom typesafe collection woes

Hi there,

I have a typesafe collection in my application called Countries, which
is derived from the ReadOnlyCollectionBase. As you might guess, the
item-value is of type Country. Each Country has (for now) and ID and a
Name property.

Now I'd like to use a CheckBoxList to display the contents of my
Countries collection and let the user select some:

// chklCountries is the CheckBoxList
Countries colCountries = new Countries();
chklCountries.DataSource = colCountries;
chklCountries.DataTextField = "Name"; // Country.Name?
chklCountries.DataValueField = "ID"; // Country.ID?
chklCountries.DataBind();

There are no countries loaded at runtime eventhough the collection works
correctly. The HTML output is a funny:

<table id="chklCountries" border="0">
</table>

That's it. What am I missing?

--
/Matthias
Nov 19 '05 #1
3 1343
JV
It's hard to tell from that snippet, but:
(1) It looks like you created an array but didn't add any items to the
array. maybe you left that out or it's hidden in the collection's
implemenation?
(2) does your Country class contain public properties or just public
member variables?
"Matthias S." <postamt@_remove_emvoid_remove_.de> wrote in message
news:OD*************@TK2MSFTNGP15.phx.gbl...
Hi there,

I have a typesafe collection in my application called Countries, which is
derived from the ReadOnlyCollectionBase. As you might guess, the
item-value is of type Country. Each Country has (for now) and ID and a
Name property.

Now I'd like to use a CheckBoxList to display the contents of my Countries
collection and let the user select some:

Nov 19 '05 #2
Agreed..but wanted to specifically point out the "funny" output...a
checkboxlist gets rendered inside a table....unless you change the
RepeatLayout to "flow" in which case it gets rendered inside <span>...it's
an empty table because, as Jv pointed out, there are no records in the
collection.

Also, the reason you need properties vs fields is that it uses the
reflection GetProperty method...just an fyi..

karl

--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is
annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
"JV" <jo**********@goisc.com> wrote in message
news:eU*************@tk2msftngp13.phx.gbl...
It's hard to tell from that snippet, but:
(1) It looks like you created an array but didn't add any items to the
array. maybe you left that out or it's hidden in the collection's
implemenation?
(2) does your Country class contain public properties or just public
member variables?
"Matthias S." <postamt@_remove_emvoid_remove_.de> wrote in message
news:OD*************@TK2MSFTNGP15.phx.gbl...
Hi there,

I have a typesafe collection in my application called Countries, which is derived from the ReadOnlyCollectionBase. As you might guess, the
item-value is of type Country. Each Country has (for now) and ID and a
Name property.

Now I'd like to use a CheckBoxList to display the contents of my Countries collection and let the user select some:


Nov 19 '05 #3
I'm honestly sorry about it guys: It was me playing blind-fish. Yes, the
collection was actually empty ;(

/Matthias

Karl Seguin wrote:
Agreed..but wanted to specifically point out the "funny" output...a
checkboxlist gets rendered inside a table....unless you change the
RepeatLayout to "flow" in which case it gets rendered inside <span>...it's
an empty table because, as Jv pointed out, there are no records in the
collection.

Also, the reason you need properties vs fields is that it uses the
reflection GetProperty method...just an fyi..

karl

Nov 19 '05 #4

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

Similar topics

5
by: rufus | last post by:
Hi, I have a custom collection class that inherits from HashTable. When I add a new CustomObject to my CustomCollection I would like to ensure that it will only accept objects of type...
0
by: Bryce Budd | last post by:
Hello All, I've been a taker of information from newsgroups for a long time and thought I'd finally make a contribution back to the community whose supported me when I've needed it. After all...
3
by: Robin Day | last post by:
I run some code on the changed event of checkbox lists. Its quite simple, nothing more than showing / hiding some other parts of the page. Using Autopostback and Server side code works fine, but is...
3
by: Dune | last post by:
Hi, Is there anyway to get the datavaluefield from a databound checkboxlist using javascript? If not, is there any way to associate a custom attribute with the databound checkboxlist items so...
19
by: Jamey Shuemaker | last post by:
I'm in the process of expanding my knowledge and use of Class Modules. I've perused MSDN and this and other sites, and I'm pretty comfortable with my understanding of Class Modules with the...
0
by: webmaster | last post by:
Hi all, I'm tearing my hair out with this one. I have successfully implemented by own RadioButtonList in order to provide additional functionality and a DIV rather than TABLE-based layout in...
0
by: jeremy | last post by:
Had a tough time figuring this one out and couldn't find a good solution, so I thought I would post this and hopefully it will help someone out. When using DataBind to dynamically bind a list to...
0
by: sean worlock | last post by:
Hello all, I have googled like crazy for this with no sucess! I have a dataset containing a table with the following fields Table===Widths ---------------------------------------------...
0
by: Andy B | last post by:
I have the following checkBoxList in a web page. I set the DataSource in the code behind (shown below the control) to a Dictionary<string, string> collection. When I run the page, I get some...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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
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...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.