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
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