G
Guest
I have gotten the following error in trying to get totals to come out on a
footer.
Server Error in '/test' Application.
----------------------------------------------------------------------------
----
DataBinder.Eval: 'System.Data.Common.DbDataRecord' does not contain a
property with the name ViewCount.
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.Web.HttpException: DataBinder.Eval:
'System.Data.Common.DbDataRecord' does not contain a property with the name
ViewCount.
Source Error:
Line 69: If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType =
ListItemType.AlternatingItem Then
Line 70: 'Snip out the ViewCount
Line 71: Dim viewCount As Integer =
Convert.ToInt32(DataBinder.Eval(e.Item.DataItem, "ViewCount"))
Line 72: viewCountSum += viewCount
Line 73: ElseIf e.Item.ItemType = ListItemType.Footer Then
Source File: c:\inetpub\wwwroot\test\Sales\j2list.aspx.vb Line: 71
Stack Trace:
[HttpException (0x80004005): DataBinder.Eval:
'System.Data.Common.DbDataRecord' does not contain a property with the name
ViewCount.]
System.Web.UI.DataBinder.GetPropertyValue(Object container, String
propName)
System.Web.UI.DataBinder.Eval(Object container, String[] expressionParts)
System.Web.UI.DataBinder.Eval(Object container, String expression)
test.j2list.mydatagrid_itemdatabound(Object sender, DataGridItemEventArgs
e) in c:\inetpub\wwwroot\test\Sales\j2list.aspx.vb:71
System.Web.UI.WebControls.DataGrid.OnItemDataBound(DataGridItemEventArgs
e)
System.Web.UI.WebControls.DataGrid.CreateItem(Int32 itemIndex, Int32
dataSourceIndex, ListItemType itemType, Boolean dataBind, Object dataItem,
DataGridColumn[] columns, TableRowCollection rows, PagedDataSource
pagedDataSource)
System.Web.UI.WebControls.DataGrid.CreateControlHierarchy(Boolean
useDataSource)
System.Web.UI.WebControls.BaseDataList.OnDataBinding(EventArgs e)
System.Web.UI.WebControls.BaseDataList.DataBind()
test.j2list.BindGrid() in c:\inetpub\wwwroot\test\Sales\j2list.aspx.vb:59
test.j2list.Page_Load(Object sender, EventArgs e) in
c:\inetpub\wwwroot\test\Sales\j2list.aspx.vb:49
System.Web.UI.Control.OnLoad(EventArgs e)
System.Web.UI.Control.LoadRecursive()
System.Web.UI.Page.ProcessRequestMain()
The code that generates the error is here:
Public Sub mydatagrid_itemdatabound(ByVal sender As Object, ByVal e As
DataGridItemEventArgs)
If (e.Item.ItemType = ListItemType.Footer) Then
Dim rows As Integer
rows = DataGrid1.Items.Count
e.Item.Cells(6).Text = "Total Purchase Orders: (" & rows & ")"
End If
If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType =
ListItemType.AlternatingItem Then
'Snip out the ViewCount
Dim viewCount As Integer = Convert.ToInt32(DataBinder.Eval(e.Item.DataItem,
"ViewCount"))
viewCountSum += viewCount
ElseIf e.Item.ItemType = ListItemType.Footer Then
'e.Item.Cells(11).Text = "Total: " & String.Format("{0:#,###}",
viewCountSum)
e.Item.Cells(11).Text = viewCountSum
End If
End Sub
If I comment out the Viewcount in the second part of the Sub, it works fine,
putting out a count in the footer of the number of rows in the datagrid.
Stepping through the code, it will go thru the if statements once on the
header, and then it'll blow up on the footer. I want to put a count of the
rows in column 6, and then put totals of columns 11, 12 & 13 in the footer.
Any ideas as to what's happening?
SC
footer.
Server Error in '/test' Application.
----------------------------------------------------------------------------
----
DataBinder.Eval: 'System.Data.Common.DbDataRecord' does not contain a
property with the name ViewCount.
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.Web.HttpException: DataBinder.Eval:
'System.Data.Common.DbDataRecord' does not contain a property with the name
ViewCount.
Source Error:
Line 69: If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType =
ListItemType.AlternatingItem Then
Line 70: 'Snip out the ViewCount
Line 71: Dim viewCount As Integer =
Convert.ToInt32(DataBinder.Eval(e.Item.DataItem, "ViewCount"))
Line 72: viewCountSum += viewCount
Line 73: ElseIf e.Item.ItemType = ListItemType.Footer Then
Source File: c:\inetpub\wwwroot\test\Sales\j2list.aspx.vb Line: 71
Stack Trace:
[HttpException (0x80004005): DataBinder.Eval:
'System.Data.Common.DbDataRecord' does not contain a property with the name
ViewCount.]
System.Web.UI.DataBinder.GetPropertyValue(Object container, String
propName)
System.Web.UI.DataBinder.Eval(Object container, String[] expressionParts)
System.Web.UI.DataBinder.Eval(Object container, String expression)
test.j2list.mydatagrid_itemdatabound(Object sender, DataGridItemEventArgs
e) in c:\inetpub\wwwroot\test\Sales\j2list.aspx.vb:71
System.Web.UI.WebControls.DataGrid.OnItemDataBound(DataGridItemEventArgs
e)
System.Web.UI.WebControls.DataGrid.CreateItem(Int32 itemIndex, Int32
dataSourceIndex, ListItemType itemType, Boolean dataBind, Object dataItem,
DataGridColumn[] columns, TableRowCollection rows, PagedDataSource
pagedDataSource)
System.Web.UI.WebControls.DataGrid.CreateControlHierarchy(Boolean
useDataSource)
System.Web.UI.WebControls.BaseDataList.OnDataBinding(EventArgs e)
System.Web.UI.WebControls.BaseDataList.DataBind()
test.j2list.BindGrid() in c:\inetpub\wwwroot\test\Sales\j2list.aspx.vb:59
test.j2list.Page_Load(Object sender, EventArgs e) in
c:\inetpub\wwwroot\test\Sales\j2list.aspx.vb:49
System.Web.UI.Control.OnLoad(EventArgs e)
System.Web.UI.Control.LoadRecursive()
System.Web.UI.Page.ProcessRequestMain()
The code that generates the error is here:
Public Sub mydatagrid_itemdatabound(ByVal sender As Object, ByVal e As
DataGridItemEventArgs)
If (e.Item.ItemType = ListItemType.Footer) Then
Dim rows As Integer
rows = DataGrid1.Items.Count
e.Item.Cells(6).Text = "Total Purchase Orders: (" & rows & ")"
End If
If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType =
ListItemType.AlternatingItem Then
'Snip out the ViewCount
Dim viewCount As Integer = Convert.ToInt32(DataBinder.Eval(e.Item.DataItem,
"ViewCount"))
viewCountSum += viewCount
ElseIf e.Item.ItemType = ListItemType.Footer Then
'e.Item.Cells(11).Text = "Total: " & String.Format("{0:#,###}",
viewCountSum)
e.Item.Cells(11).Text = viewCountSum
End If
End Sub
If I comment out the Viewcount in the second part of the Sub, it works fine,
putting out a count in the footer of the number of rows in the datagrid.
Stepping through the code, it will go thru the if statements once on the
header, and then it'll blow up on the footer. I want to put a count of the
rows in column 6, and then put totals of columns 11, 12 & 13 in the footer.
Any ideas as to what's happening?
SC