473,836 Members | 1,523 Online
Bytes | Software Development & Data Engineering Community
+ 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 ReadOnlyCollect ionBase. 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.D ataSource = colCountries;
chklCountries.D ataTextField = "Name"; // Country.Name?
chklCountries.D ataValueField = "ID"; // Country.ID?
chklCountries.D ataBind();

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

<table id="chklCountri es" border="0">
</table>

That's it. What am I missing?

--
/Matthias
Nov 19 '05 #1
3 1363
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@_remov e_emvoid_remove _.de> wrote in message
news:OD******** *****@TK2MSFTNG P15.phx.gbl...
Hi there,

I have a typesafe collection in my application called Countries, which is
derived from the ReadOnlyCollect ionBase. 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**********@g oisc.com> wrote in message
news:eU******** *****@tk2msftng p13.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@_remov e_emvoid_remove _.de> wrote in message
news:OD******** *****@TK2MSFTNG P15.phx.gbl...
Hi there,

I have a typesafe collection in my application called Countries, which is derived from the ReadOnlyCollect ionBase. 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
2193
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 CustomObject. How would I do this? Thanks in advance. Public Class CustomCollection Inherits Hashtable ' default constructor
0
7953
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 before commercialization took over that was the beauty of the Internet! I've create a checkboxlist validator control...something MS should have done originally in my opinion, but nonetheless here it is. It's a C# control, sort of IE specific. ...
3
5459
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 far too slow, especially if the users are on modems. I need to quite simply, add some java code to the onclick event of the input tags of a checkboxlist. However... Attributes.Add adds the onclick attribute and code to the outlying table that...
3
5532
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 that the custom attribute can be accessed using javascript? Cheers
19
4926
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 exception of custom Collection Classes. Background: I'm developing an A2K .mdb to be deployed as an .mde at my current job-site. It has several custom controls which utilize custom classes to wrap built-in controls, and add additional functionality....
0
2162
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 one of my ASP.NET 1.1 web forms. This involves a fairly simple inheritance of the System.Web.UI.WebControls.RadioButtonList class, with some new properties added and the Render sub overridden. When I come to render each radio item, I do the...
0
11016
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 the CheckBoxList control in ASP .NET, I had a hard time figuring out how to dynamically select the items that needed to be selected. Specifically, I was displaying checkboxes for Roles, and I wanted to check the boxes of the roles that were...
0
1356
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 --------------------------------------------- WidthID---int (primary key) Width------decimal
0
1932
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 formatting in the control that I want to change. For this example, I get the key/value pair of the dictionary inside of (). For example: Page output:
0
9825
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9671
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10846
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10551
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10595
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9379
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5828
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4458
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 we have to send another system
3
3116
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.