473,395 Members | 1,999 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,395 software developers and data experts.

Custom Classes and DropDownList Web Controls

Hi All,

Hope someone can help me out on this one, it's been driving me around
the bend.

In essence I'm trying to replicate a custom class hierachy relating to
my problem domain database. The actual domain I'm working on is
irrelevant, so I've been playing with two noddy classes; Person and Pet
(the full code can be found here:
<http://www.junge.f9.co.uk/code/CustomClassDDL.zip>).

The notion is a Person has a Pet, so the Pet is a property of the
Person object. However when I try and use this relationship against a
DropDownList I can't figure out how to get it to work, as in:

Pet moDino = new Pet(1, "Dino", 4);
Person moFranz = new Person(99, "Mr", "Flintstone", moDino);

ArrayList marrPeople = new ArrayList();

marrPeople.Add(moFranz);

ddlPeople.DataValueField = "Id";
ddlPeople.DataTextField = "MyPet.Name";
ddlPeople.DataSource = marrPeople;
ddlPeople.DataBind();

I've also tried variations like:
ddlPeople.DataTextField = "((Pet) MyPet).Name";

but still didn't get anywhere :(

I just get the error "DataBinder.Eval: 'Person' does not contain a
property with the name MyPet.Name."

However I know I can do this in a datagrid by casting in the
DataBinder.Eval in the HTML view, but can't figure the equivalent for
the code behind :(

Any help much appreciated :)

Nov 19 '05 #1
0 817

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

Similar topics

0
by: Sundown | last post by:
I am trying to create a custom button control for the web that, when clicked, disables and changes the text of itself and a bunch of other controls (in the collection). My goal is to end up with a...
0
by: Steve R | last post by:
I've built a composite web custom control with a lot of child controls. I assigned ToolTip values to some of these controls. The ToolTip pop-ups were working fine until I monkeyed with the order...
2
by: Pham Nguyen | last post by:
Has anyone seen an example of a textbox server control that has built-in client-side validation? I'd like to build a server control that extends the System.Web.UI.WebControls.TextBox class to allow...
7
by: Girish | last post by:
OK.. phew. Playing with data grids for the past few days has been fun and a huge learning experience.. My problem. I have a requirement to display a gird with a gird. Within the embedded grid,...
0
by: fwirtanen | last post by:
I am building a custom composite control consisting of two drop downs, with parent/child dependancy. The child dropdownlist is updated through client callback when the parent index changes. ...
2
by: Pipo | last post by:
Nobody knows how to get the values provided in the client can be read in the user-control? If have made a Web Custom Control with 2 textboxes and 1 dropdownlist. The user fills in my control (the...
1
by: Joe | last post by:
Hello All: I have created a class (UpdatedDropDown) that inherits from DropDownList and I have included the following code in this class: Public Class UpdatedDropDown Inherits DropDownList ...
0
by: pabloazorin | last post by:
I developed a Date Picker web control using C# and .net framework 1.1 I added my control to Visual Studio 2003 IDE toolbar. When I drag and drop my control to design web page, the control renders...
0
by: tsw_mik | last post by:
I have created a custom control. It has: -label -button -list of textboxes -list of dropdownlists. I want to use a custom validator to perform some validation, but somehow I can't fo it. The...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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
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
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,...

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.