Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > DataBinding to Array of Custom Objects

Reply
Thread Tools

DataBinding to Array of Custom Objects

 
 
Jed
Guest
Posts: n/a
 
      11-10-2004
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!

 
Reply With Quote
 
 
 
 
Bob Barrows [MVP]
Guest
Posts: n/a
 
      11-10-2004
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"


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Databinding expressions are only supported on objects that have a DataBinding event jobs ASP .Net 0 09-25-2007 11:54 PM
Databinding to custom properties of a custom class in ASP.NET 2 =?Utf-8?B?SW1hciBTcGFhbmphYXJz?= ASP .Net 0 04-20-2005 07:34 PM
DropDownList: Complex DataBinding with Custom Business Objects Dan Caron ASP .Net Web Controls 1 11-03-2004 08:43 AM
Databinding to arrays of custom objects returned from a webservice Chris McKenzie ASP .Net Web Services 0 04-22-2004 08:30 PM
DataGrid Custom Column Error when DataBinding "does not contain a definition for 'DataBinding'" Earl Teigrob ASP .Net Datagrid Control 1 03-01-2004 04:52 AM



Advertisments