Error when databinding

Ask a Question related to ASP.NET Data Grid Control, Design and Development.

  1. #1

    Default Error when databinding

    When I run my application, which uses databinding in a DataList, I recieve the following error:

    Server Error in '/' Application.
    --------------------------------------------------------------------------------

    Public member 'title' on type 'DataRowView' not found.
    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.MissingMemberException: Public member 'title' on type 'DataRowView' not found.

    Source Error:

    Line 65: <ItemStyle Font-Names="Arial,Helvetica,Sans-Serif" BackColor="Silver"></ItemStyle>
    Line 66: <ItemTemplate>
    Line 67: <asp:HyperLink id=lnkTitle1 runat="server" NavigateUrl='<%# "viewpoem.aspx?poem=" &amp; Server.UrlEncode(Container.DataItem.title) %>' Text='<%# DataBinder.Eval(Container, "DataItem.title") %>' Width="400px" Font-Size="Medium">
    Line 68: </asp:HyperLink>
    Line 69: <asp:Label id=lblRating1 runat="server" Text="<%# FormatNumber(CDbl(Container.DataItem.totalpoints)/CDbl(Container.DataItem..timesrated),1,TriState.Tr ue) %>" Width="40px" Font-Size="Medium">

    Source File: c:\inetpub\wwwroot\poetry\poemratings.aspx Line: 67

    Stack Trace:

    [MissingMemberException: Public member 'title' on type 'DataRowView' not found.]
    Microsoft.VisualBasic.CompilerServices.LateBinding .LateGet(Object o, Type objType, String name, Object[] args, String[] paramnames, Boolean[] CopyBack) +885
    ASP.poemratings_aspx.__DataBind__control12(Object sender, EventArgs e) in c:\inetpub\wwwroot\poetry\poemratings.aspx:67
    System.Web.UI.Control.OnDataBinding(EventArgs e) +66
    System.Web.UI.Control.DataBind() +26
    System.Web.UI.Control.DataBind() +86
    System.Web.UI.WebControls.DataList.CreateItem(Int3 2 itemIndex, ListItemType itemType, Boolean dataBind, Object dataItem) +127
    System.Web.UI.WebControls.DataList.CreateControlHi erarchy(Boolean useDataSource) +686
    System.Web.UI.WebControls.BaseDataList.OnDataBindi ng(EventArgs e) +49
    System.Web.UI.WebControls.BaseDataList.DataBind() +23
    localhost.poetry.poemratings.SortPoems(String sortby) in C:\Inetpub\wwwroot\poetry\poemratings.aspx.vb:59
    localhost.poetry.poemratings.Page_Load(Object sender, EventArgs e) in C:\Inetpub\wwwroot\poetry\poemratings.aspx.vb:41
    System.Web.UI.Control.OnLoad(EventArgs e) +67
    System.Web.UI.Control.LoadRecursive() +35
    System.Web.UI.Page.ProcessRequestMain() +750



    --------------------------------------------------------------------------------
    Version Information: Microsoft .NET Framework Version:1.1.4322.2032; ASP.NET Version:1.1.4322.2032


    I cannot figure out why this is happening. The code I use to do the binding, which I call from Page_Load using Me.SortPoems("title") is as follows:


    Private Sub SortPoems(ByVal sortby As String)
    Dim ratedpoems As New DataSet
    Dim sqltext As String = "SELECT * FROM poemratings ORDER BY "

    Select Case sortby
    Case "title"
    sqltext &= "title"
    Case "rating"
    sqltext &= "(totalpoints/timesrated),timesrated,title"
    Case "timesrated"
    sqltext &= "timesrated,(totalpoints/timesrated),title"
    End Select
    Dim dataadapterSelect As New System.Data.OleDb.OleDbDataAdapter(sqltext, Global.GetDBConnection())
    dataadapterSelect.Fill(ratedpoems)
    datRatings.DataSource = ratedpoems
    datRatings.DataBind()
    End Sub


    I have tried several experiments (such as removing the databinding expressions that use the field, but the same thing happens with the other fields). Why is ASP.NET telling me the field is not there? Any help would be appreciated. Thanks.
    --
    Nathan Sokalski
    [email]njsokalski@hotmail.com[/email]
    [url]http://www.nathansokalski.com/[/url]
    Nathan Sokalski Guest

  2. Similar Questions and Discussions

    1. Databinding HierarchicalDataBoundControl
      I am trying to write a Hierarchical using HierarchicalDataBoundControl I have looked at both the treeview and menu but there implementations depend...
    2. databinding
      have two Dropdownlist and one which is containing States and one containing Cities. I know how to do all the little databinding task in visual...
    3. databinding & classes
      I made an arraylist wich contains a certain amount of objects from the class 'employees'. The class 'employees' contains also an object...
    4. DataGrid Custom Column Error when DataBinding "does not contain a definition for 'DataBinding'"
      I am creating a custom column that inherits from DataColumnGrid. When I attempt Databind to a property of the custom column, I get the the error: ...
    5. Databinding Query
      Thanks, How do I go about accessing the data from within the codebehind? Thanks, Carl "Ravikanth" <dvravikanth@hotmail.com> wrote in message...
  3. #2

    Default Re: Error when databinding

    Nathan

    Try it in this case with a datatable.

    I hope this helps,

    Cor


    Cor Ligthert [MVP] Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139