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

DataBinding to Array of Custom Objects

Jed
I have a web service method that returns an array of custom objects marked
serializeable with fully described public properties.

When I bind the results to a DataGrid I can access the properties in the
ItemDataBound event of the codebehind but I can't access them declaratively
in the HTML code?

Here is the code to call the method.
net.mysite.www.WSInterface proxy;
proxy = new net.mysite.www.WSInterface();
ProjectList[] pl = proxy.getProjects("%",false,true);
this.DataGrid1.DataSource = pl;
this.DataGrid1.DataBind();

Here is the code to access the property in the Item databound event.
lbl.Text = ((ProjectList)dg.DataItem).ClientName;

Here is the code that won't work on the HTML side:
Option 1:
<asp:BoundColumn HeaderText="Client Contact"
DataField="ClientContact"></asp:BoundColumn>

Option 2:
<asp:TemplateColumn HeaderText="Contact">
<ItemTemplate><%# DataBinder.Eval(Container.DataItem,
"ClientContact")%></ItemTemplate>
</asp:TemplateColumn>

Here is the error:
DataBinder.Eval: 'net.mysite.www.ProjectList' does not contain a property
with the name ClientContact.

Why can I access the property in the ItemDataBound event but not on the
declarative side?

The Page obviously know what kind of Object the data item is, otherwise the
error could not report it.

Any ideas? Thanks!

Jul 21 '05 #1
1 1081
Jed wrote:
I have a web service method that returns an array of custom objects
marked serializeable with fully described public properties.

When I bind the results to a DataGrid I can access the properties in


There was no way for you to know it, but this is a classic asp newsgroup.
While you may be lucky enough to find a dotnet-savvy person here who can
answer your question, you can eliminate the luck factor by posting your
question to a group where those dotnet-savvy people hang out. I suggest
microsoft.public.dotnet.framework.adonet or
microsoft.public.dotnet.framework.aspnet.

--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
Jul 21 '05 #2

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

Similar topics

1
by: D. Shane Fowlkes | last post by:
This should be easy but I'm having a little trouble connecting the logical dots. I have a function which simply returns the 12 month names. Whoopie. I'm trying to store that data into an...
1
by: Andy Fish | last post by:
Hi, Say I have an Array of "Person" objects that I'm using as the DataSource for a grid control. At databinding time I'd like to select only people with age>18 to go into the grid and ignore all...
3
by: John Bailey | last post by:
When I first built a few web pages in ASP .Net 2.0, I thought it was great. The formview and detailview contorls would automatically layout the controls for you, the update methods were...
1
by: Solitus | last post by:
I have databinding problem with a repeater <ItemTemplate> <tr> <!-- fixed content --> </tr> <tr> <!-- optional content --> </tr> </ItemTemplate>
5
by: Trail Monster | last post by:
Ok, I've been searching the net now for several days and can't find how to do this anywhere. Version: VS 2005 Professional Release, 2.0 Framework Background: I have a complex business object...
8
by: GaryDean | last post by:
We have been noticing that questions on vs.2005/2.0 don't appear to get much in answers so I'm reposting some questions posted by some of the programmers here in our organization that never got...
8
by: Joey Chömpff | last post by:
L.S., Hello is there a way to implement 2-way databinding without using the datasources from dotnet 2.0. Why would you ask? Now that's simple. I've created an object model with BusinessObjects...
1
by: Mark Olbert | last post by:
Has anyone else noticed that the design-time support for databinding in custom controls in ASPNET2 sucks? At least for GridViews? So far I've spent going on two days trying to get the following...
3
by: jimmarq | last post by:
Please help me with this databinding scenario: Suppose I have a "Person" class, and that users populate Person objects in a BindingList collection through a datagridview. Users save the Person...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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...

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.