DataKeyField causes DataBinder.Eval error

  • Thread starter Michael Freidgeim
  • Start date
M

Michael Freidgeim

Hi all,

I am using ASP.NET datagrid to show results of GOOGLE API web service.
It works fine unless I try to set DataKeyField property to the datagrid.

My grid properties are the following
<asp:datagrid id="grInternetURLs" runat="server" GridLines="Horizontal"
AutoGenerateColumns="False"
AllowPaging="True" PageSize="2" AllowCustomPaging="True"
DataKeyField="URL">


In this case the following exception is reported:
System.Web.HttpException: DataBinder.Eval: 'FSWeb.Google.ResultElement'
does not contain a property with the name URL.
at System.Web.UI.DataBinder.GetPropertyValue(Object container, String
propName)
at System.Web.UI.WebControls.DataGrid.CreateControlHierarchy(Boolean
useDataSource)
at System.Web.UI.WebControls.BaseDataList.OnDataBinding(EventArgs e)
at System.Web.UI.WebControls.BaseDataList.DataBind()
at FSWeb.results2.gridResultsDataBind(DataGrid grd, IEnumerable
dataSource, Int32 nCount, Label lblResultCount, Type resType).

DataBinding accepts referrence to URL inside templatecolumns eg
<asp:hyperlink runat="server" id="lnkInternetURL" NavigateUrl='<%#
Container.DataItem.URL %>'>Link </asp:hyperlink>

It seems that DataBinder checks only PROPERTIES, not public fields.
But when VS.NET generated proxy class for Google
API("http://api.google.com/search/beta2"), it created Public Class
ResultElement with
Public URL As String

How can I workaround the issue to be able to use DataKeyField?

Michael Freidgeim
Add ".com.au" to my e-mail address to reach me by e-mail
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,050
Latest member
AngelS122

Latest Threads

Top