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

Problems binding propertyless class to a Repeater

I am digesting a web serivce from Amazon.Com. I have the following
class which was autogenerated by VS.NET when I created a Web Reference
to http://webservices.amazon.com/AWSECo...ceService.wsdl

AmazonWebService.com.amazon.webservices.Item

As you can see from the code snippets below it has public member
variables rather than public Properties. When I use <%#
DataBinder.Eval(Container.DataItem, "ASIN") %> syntax in Repeater1 in
my aspx page I get the following error.

[HttpException (0x80004005): DataBinder.Eval:
'AmazonWebService.com.amazon.webservices.Item' does not contain a
property with the name ASIN.]
System.Web.UI.DataBinder.GetPropertyValue(Object container, String
propName)
System.Web.UI.DataBinder.Eval(Object container, String[]
expressionParts)
System.Web.UI.DataBinder.Eval(Object container, String expression)
ASP.SearchForm_aspx.__DataBind__control8(Object sender, EventArgs e)
in c:\inetpub\wwwroot\AmazonWebService\SearchForm.asp x:33
System.Web.UI.Control.OnDataBinding(EventArgs e)
System.Web.UI.Control.DataBind()
System.Web.UI.Control.DataBind()
System.Web.UI.WebControls.Repeater.CreateItem(Int3 2 itemIndex,
ListItemType itemType, Boolean dataBind, Object dataItem)
System.Web.UI.WebControls.Repeater.CreateControlHi erarchy(Boolean
useDataSource)
System.Web.UI.WebControls.Repeater.OnDataBinding(E ventArgs e)
System.Web.UI.WebControls.Repeater.DataBind()
AmazonWebService.Web.SearchForm.Button1_Click(Obje ct sender, EventArgs
e) in c:\inetpub\wwwroot\amazonwebservice\searchform.asp x.cs:83
System.Web.UI.WebControls.Button.OnClick(EventArgs e)
System.Web.UI.WebControls.Button.System.Web.UI.IPo stBackEventHandler.RaisePostBackEvent(String
eventArgument)
System.Web.UI.Page.RaisePostBackEvent(IPostBackEve ntHandler
sourceControl, String eventArgument)
System.Web.UI.Page.RaisePostBackEvent(NameValueCol lection postData)
System.Web.UI.Page.ProcessRequestMain()

If I add a property to the Item class called ASINP, which encapsulates
ASIN member variable, and I use <%#
DataBinder.Eval(Container.DataItem, "ASINP") %> syntax in Repeater1 on
my aspx then everything works fine. Since the Item class is
autogenerated I do not want to have to add Properties in every
autogenerated class because I have about 40 auto generated classes.
How can I reference the memeber variable ASIN in the aspx page, or any
other memeber variable in that class.

Please see the code snippets below if you have questions.

Thanks,
Chris Gastin

CODE SNIPPETS:
////////////////////////////////////////////////////////////////////////////////////////////////////
// asp:Repeater
///////////////////////////////////////////////////////////////////////////////////////////////////
<asp:Repeater id="Repeater1" runat="server">
<HeaderTemplate>
<table border=1>
<tr>
<td>Results:</td>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td bgcolor="LightGrey">
<%# DataBinder.Eval(Container.DataItem, "ASIN") %>
</td>
</tr>
</ItemTemplate>
<AlternatingItemTemplate>
<tr>
<td bgcolor="Yellow">
<%# DataBinder.Eval(Container.DataItem, "ASIN") %>
</td>
</tr>
</AlternatingItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>


////////////////////////////////////////////////////////////////////////////////////////////////////
// Button Click Event
///////////////////////////////////////////////////////////////////////////////////////////////////
private void Button1_Click(object sender, System.EventArgs e)
{
AWSECommerceService svc = new AWSECommerceService();
ItemSearchRequest itemSearchRequest = new ItemSearchRequest();
itemSearchRequest.Keywords = TextBox1.Text;
itemSearchRequest.SearchIndex = DropDownList1.SelectedValue;
itemSearchRequest.MerchantId = "All";
itemSearchRequest.ResponseGroup = new string[]{"Large"};
ItemSearch search = new ItemSearch();
search.SubscriptionId =
ConfigurationSettings.AppSettings["SubscriptionId"];
search.Request = new ItemSearchRequest[]{itemSearchRequest};
IAsyncResult result = svc.BeginItemSearch(search,null,null);
ItemSearchResponse searchResponse = svc.EndItemSearch(result);

Repeater1.DataSource = searchResponse.Items[0].Item;
Repeater1.DataBind();
}
////////////////////////////////////////////////////////////////////////////////////////////////////
// Item Class
///////////////////////////////////////////////////////////////////////////////////////////////////

/// <remarks/>
[System.Xml.Serialization.XmlTypeAttribute(Namespac e="http://webservices.amazon.com/AWSECommerceService/2004-10-19")]
public class Item {

/// <remarks/>
public string ASIN;

/// <remarks/>
[System.Xml.Serialization.XmlArrayItemAttribute("Er ror",
IsNullable=false)]
public ErrorsError[] Errors;

/// <remarks/>
public string DetailPageURL;

/// <remarks/>
public string SalesRank;

/// <remarks/>
public Image SmallImage;

/// <remarks/>
public Image MediumImage;

/// <remarks/>
public Image LargeImage;

/// <remarks/>
public ItemAttributes ItemAttributes;

/// <remarks/>
public OfferSummary OfferSummary;

/// <remarks/>
public Offers Offers;

/// <remarks/>
public VariationSummary VariationSummary;

/// <remarks/>
public Variations Variations;

/// <remarks/>
public CustomerReviews CustomerReviews;

/// <remarks/>
[System.Xml.Serialization.XmlArrayItemAttribute("Ed itorialReview",
IsNullable=false)]
public string[] EditorialReviews;

/// <remarks/>
[System.Xml.Serialization.XmlArrayItemAttribute("Si milarProduct",
IsNullable=false)]
public SimilarProductsSimilarProduct[] SimilarProducts;

/// <remarks/>
[System.Xml.Serialization.XmlArrayItemAttribute("Si milarBusiness",
IsNullable=false)]
public SimilarBusinessesSimilarBusiness[] SimilarBusinesses;

/// <remarks/>
[System.Xml.Serialization.XmlArrayItemAttribute("Ac cessory",
IsNullable=false)]
public AccessoriesAccessory[] Accessories;

/// <remarks/>
[System.Xml.Serialization.XmlArrayItemAttribute("Di sc",
IsNullable=false)]
public TracksDisc[] Tracks;

/// <remarks/>
public BrowseNodes BrowseNodes;

/// <remarks/>
[System.Xml.Serialization.XmlArrayItemAttribute("Li stmaniaList",
IsNullable=false)]
public ListmaniaListsListmaniaList[] ListmaniaLists;

/// <remarks/>
public SearchInside SearchInside;

/// <remarks/>
public PromotionalTag PromotionalTag;
}
Nov 16 '05 #1
0 1443

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

Similar topics

2
by: Paul K | last post by:
I'm having a problem getting the data binding to work with the repeater control. Here's the code for the code-behind class private void Page_Load(object sender, System.EventArgs e if...
2
by: Gastin | last post by:
I am consuming a web serivce from Amazon.Com. I have the following class which was autogenerated by VS.NET when I created a Web Reference to...
12
by: =?Utf-8?B?Qi4gQ2hlcm5pY2s=?= | last post by:
I'm doing a web app in VB/Dot Net 2.0. I'm probably a bit rusty and I have no experience using the repeater control. I have a user control I've created with multiple properties. I've created a...
1
markrawlingson
by: markrawlingson | last post by:
Hello, For starters: Yes, I am new to asp.net, however I hold a good 9-10 years of experience working with classic asp and am only just now upgrading my skills. I'm picking asp.net up pretty...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
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: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.