Home     |     .Net Programming    |     cSharp Home    |     Sql Server Home    |     Javascript / Client Side Development     |     Ajax Programming

Ruby on Rails Development     |     Perl Programming     |     C Programming Language     |     C++ Programming     |     IT Jobs

Python Programming Language     |     Laptop Suggestions?    |     TCL Scripting     |     Fortran Programming     |     Scheme Programming Language

Cervo Technologies
The Right Source to Outsource

MS Dynamics CRM 3.0

Asp.Net Programming

DataField, Binding to a property one level down


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

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
Any input appriciated,

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?

Add to del.icio.us | Digg this | Stumble it | Powered by Megasolutions Inc