Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Datagrid Control > DataKeyField causes DataBinder.Eval error

Thread Tools

DataKeyField causes DataBinder.Eval error

Michael Freidgeim
Posts: n/a
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"
AllowPaging="True" PageSize="2" AllowCustomPaging="True"

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
at System.Web.UI.WebControls.DataGrid.CreateControlHi erarchy(Boolean
at System.Web.UI.WebControls.BaseDataList.OnDataBindi ng(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(""), 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 "" to my e-mail address to reach me by e-mail

*** Sent via Developersdex ***
Don't just participate in USENET...get rewarded for it!
Reply With Quote

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
DataGrid - DataKeyField!! Adam Knight ASP .Net 0 08-07-2005 02:33 PM
Newbie question: ASP Datagrid + Complex DataKeyField Homer J. Simpson ASP .Net 2 03-05-2004 06:34 PM
DatakeyField with multi-column primary key Beryl Small ASP .Net 0 03-01-2004 12:24 AM
Composite DataKeyField? Felbrigg ASP .Net 4 02-11-2004 07:46 AM
datakeyfield and 3 fields making up the PK sramruttun ASP .Net 0 07-10-2003 06:49 AM