DataKeyField causes DataBinder.Eval error

Discussion in 'ASP .Net Datagrid Control' started by Michael Freidgeim, Sep 6, 2004.

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

    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
     
    Michael Freidgeim, Sep 6, 2004
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Don Pedro
    Replies:
    0
    Views:
    489
    Don Pedro
    Jul 3, 2003
  2. Simon Storr

    Complete syntax of DataBinder.Eval() ?

    Simon Storr, Jul 30, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    424
    Simon Storr
    Jul 30, 2003
  3. Eric Newton
    Replies:
    3
    Views:
    9,557
    Brock Allen
    Apr 4, 2005
  4. Lam

    DataBinder.Eval: error

    Lam, Aug 24, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    796
    Sparky Arbuckle
    Aug 24, 2005
  5. DataBinder.Eval and Eval.

    , Jun 16, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    573
    Karl Seguin [MVP]
    Jun 16, 2006
Loading...

Share This Page