G
Guest
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!
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!