473,396 Members | 2,021 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,396 software developers and data experts.

DataField, Binding to a property one level down

VJ
Hi,

I'm certain I'm not the first person to run into this, but here's the
scenario:

I have a collection of objects say of class 'User' which I want to put
as the datasource of a GridView. I can bind to properties of User
fine. But suppose I want to bind to a property one level down. (Say
User has a property of class Name which has 2 properties 'FirstName'
and 'LastName', both strings. So I'd like to be able to put:

<... DataField="Name.FirstName"..(in xml)
DataField="Name.FirstName'; (in C#)

As far as I know the first is possible (it's smart enough to traverse
down and find FirstName) while the second is not.

My question is why exactly is this and what's a simple or elegant
workaround (using just code behind). I don't want to create a new
class just so that it's more convinient to bind to the grid view, nor
do I want to copy things manually into a datatable, or anything like
that.
Any input appriciated,
VJ

Feb 10 '07 #1
1 1098
Hi VJ,

I don't actually think both methods (aspx code and c#) will work for
boundfield (i tested it). However, it will work for templatefield and
Eval("Name.FirstName"). BTW, have you worked for Image Int?
--
Milosz
"VJ" wrote:
Hi,

I'm certain I'm not the first person to run into this, but here's the
scenario:

I have a collection of objects say of class 'User' which I want to put
as the datasource of a GridView. I can bind to properties of User
fine. But suppose I want to bind to a property one level down. (Say
User has a property of class Name which has 2 properties 'FirstName'
and 'LastName', both strings. So I'd like to be able to put:

<... DataField="Name.FirstName"..(in xml)
DataField="Name.FirstName'; (in C#)

As far as I know the first is possible (it's smart enough to traverse
down and find FirstName) while the second is not.

My question is why exactly is this and what's a simple or elegant
workaround (using just code behind). I don't want to create a new
class just so that it's more convinient to bind to the grid view, nor
do I want to copy things manually into a datatable, or anything like
that.
Any input appriciated,
VJ

Feb 10 '07 #2

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

Similar topics

17
by: Jochen Luebbers | last post by:
Hi, I've a problem: I compile modules of embedded SQL (for a dynamic lib) on multiple platforms (AIX,Linux,Windows). They are compiled from the same source code. To be able to provide all...
0
by: Jason | last post by:
What interface do I need to implement in order to get a component with a public property to show up in the data binding drop down boxes at design time in VS.net? I've tried to look just about...
4
by: Alan Silver | last post by:
Hello, I'm trying to use an ArrayList to do data binding, but am getting an error I don't understand. I posted this in another thread, but that was all confused with various other problems,...
19
by: Simon Verona | last post by:
I'm not sure if I'm going down the correct route... I have a class which exposes a number of properties of an object (in this case the object represents a customer). Can I then use this...
0
by: Blibo Baggins | last post by:
How do you get the "Datafield" property of data that's in a Template Column of a Grid? I am using editable Datagrids with Template Columns. When using Boundcolumns, I just used: ColName =...
2
by: mark | last post by:
I understand that writing programs with option strict on is the best way to obtain stable applications. I have also found the applications to run much faster. Option strict on disallows late...
2
by: Larry Lard | last post by:
Here's the scenario: Show the user a list of Things. User picks one, and the Thing edit frame is populated with the details of the Thing they picked. This frame has Save / Discard buttons that...
6
by: Dmitry Duginov | last post by:
Hi, I have the following label markup (label is inside FormView): <asp:Label ID="lblIndicatorReady" runat="server" Text="RE" ToolTip="Ready" BackColor='<%#...
9
by: =?Utf-8?B?VGVycnk=?= | last post by:
Think it is great the way that you can set up a datsource, value member, and display member for a combobox, and map a 'code' to a 'description' and back again by binding the combobox to a...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
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.