Groups | Blog | Home
all groups > asp.net datagrid control > september 2005 >

asp.net datagrid control : Error when databinding



Nathan Sokalski
9/22/2005 2:20:58 AM
When I run my application, which uses databinding in a DataList, I =
recieve the following error:

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

Public member 'title' on type 'DataRowView' not found.=20
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.=20

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

Source Error:=20

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

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

Stack Trace:=20

[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(Int32 itemIndex, =
ListItemType itemType, Boolean dataBind, Object dataItem) +127
System.Web.UI.WebControls.DataList.CreateControlHierarchy(Boolean =
useDataSource) +686
System.Web.UI.WebControls.BaseDataList.OnDataBinding(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
=20


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


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 =3D "SELECT * FROM poemratings ORDER BY "

Select Case sortby
Case "title"
sqltext &=3D "title"
Case "rating"
sqltext &=3D "(totalpoints/timesrated),timesrated,title"
Case "timesrated"
sqltext &=3D "timesrated,(totalpoints/timesrated),title"
End Select
Dim dataadapterSelect As New =
System.Data.OleDb.OleDbDataAdapter(sqltext, Global.GetDBConnection())
dataadapterSelect.Fill(ratedpoems)
datRatings.DataSource =3D 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.
--=20
Nathan Sokalski
njsokalski@hotmail.com
Cor Ligthert [MVP]
9/22/2005 8:44:20 AM
Nathan

Try it in this case with a datatable.

I hope this helps,

Cor

AddThis Social Bookmark Button