470,620 Members | 1,763 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,620 developers. It's quick & easy.

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 1263
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by rufus | last post: by
reply views Thread by Bryce Budd | last post: by
3 posts views Thread by Robin Day | last post: by
3 posts views Thread by Dune | last post: by
19 posts views Thread by Jamey Shuemaker | last post: by
reply views Thread by Andy B | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.