473,320 Members | 1,945 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Error trying to get totals in footer

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(Int3 2 itemIndex, Int32
dataSourceIndex, ListItemType itemType, Boolean dataBind, Object dataItem,
DataGridColumn[] columns, TableRowCollection rows, PagedDataSource
pagedDataSource)
System.Web.UI.WebControls.DataGrid.CreateControlHi erarchy(Boolean
useDataSource)
System.Web.UI.WebControls.BaseDataList.OnDataBindi ng(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

Nov 18 '05 #1
2 1435
You are asking the DataBinder to evaluate the DataTable for a property
called viewCount, which is a value you have created. If you wish to bind,
you have two options.

1. Set up a label in the footer and set the value from CodeBehind. Something
like:

MyFooterLabel.Text = viewCount.ToString()

2. Use simple binding
a. Set up viewCount as a page scoped variable

Protected viewCount As Integer = 0

In you code, you continue to set as you have. Then, you bind like so (may
have to dink with syntax - I prefer the push method (#1) instead of the pull
below):

<%# =viewCount %>

If you are using DataViews, tables, et al, you have other ways of reaching
counts. With a DataReader, you can geta count after full read.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

************************************************
Think Outside the Box!
************************************************
<me@privacy.net> wrote in message
news:eP**************@tk2msftngp13.phx.gbl...
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(Int3 2 itemIndex, Int32
dataSourceIndex, ListItemType itemType, Boolean dataBind, Object dataItem,
DataGridColumn[] columns, TableRowCollection rows, PagedDataSource
pagedDataSource)
System.Web.UI.WebControls.DataGrid.CreateControlHi erarchy(Boolean
useDataSource)
System.Web.UI.WebControls.BaseDataList.OnDataBindi ng(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

Nov 18 '05 #2
Greg:

Thanks for the response.

How do you get a label in the footer of the datagrid?
SC

"Cowboy (Gregory A. Beamer) [MVP]" <No************@comcast.netNoSpamM> wrote
in message news:OQ**************@TK2MSFTNGP10.phx.gbl...
You are asking the DataBinder to evaluate the DataTable for a property
called viewCount, which is a value you have created. If you wish to bind,
you have two options.

1. Set up a label in the footer and set the value from CodeBehind. Something like:

MyFooterLabel.Text = viewCount.ToString()

2. Use simple binding
a. Set up viewCount as a page scoped variable

Protected viewCount As Integer = 0

In you code, you continue to set as you have. Then, you bind like so (may
have to dink with syntax - I prefer the push method (#1) instead of the pull below):

<%# =viewCount %>

If you are using DataViews, tables, et al, you have other ways of reaching
counts. With a DataReader, you can geta count after full read.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

************************************************
Think Outside the Box!
************************************************
<me@privacy.net> wrote in message
news:eP**************@tk2msftngp13.phx.gbl...
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(Int3 2 itemIndex, Int32
dataSourceIndex, ListItemType itemType, Boolean dataBind, Object

dataItem, DataGridColumn[] columns, TableRowCollection rows, PagedDataSource
pagedDataSource)
System.Web.UI.WebControls.DataGrid.CreateControlHi erarchy(Boolean
useDataSource)
System.Web.UI.WebControls.BaseDataList.OnDataBindi ng(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


Nov 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Nothing | last post by:
I have a main report with several sub-reports on it. Some of the sub-reports are hidden some are visible. A few of the sub-reports hve totals calculated on them. I have a control in the sub-report...
4
by: Hans | last post by:
Hi, I want to create a report. The query looks like this: SELECT A.Name, Sum(A.Hours) AS FROM A GROUP BY A.Name; Now I want in my report to have a last line with the total hours from all....
4
by: yanyo | last post by:
hi, im trying to figure out whats the problem with this program i get a runtime error but i dont see where the problem is i tried changing declaration but nothing if somrbody can try this on their...
3
by: mark | last post by:
im keeping running totals of certain columns in a datagrid, id like to put these totals in the footer - how do i do this ? or how can i put a label into the footer ? (im displaying results using...
13
by: terrybens | last post by:
Hello, I'm using a Microsft Access 2000 Project (adp file) connected to MS SQL Server 2000 database. I have created a continous form having a detail part (results of the query) and a footer...
3
by: igotyourdotnet | last post by:
I'm using a gridview and I have it formatted using sub headings. now I need to get totals for each sub heading. Is this possible? example: BMW (sub heading) 25,000 14,252 25,000 total:...
1
by: ruthkred | last post by:
I am grouping certain sections of data in a report but whenever the group footer lands at the top of a new page it doubles the amount it should be. For example, if there was a detail line totals...
4
by: Micheal | last post by:
Greetings Access Group, Being relatively new to Access, I try to work through problems on my own and have been very successful, although I have a conundrum that I have been working on for two days...
0
by: Josetta | last post by:
Here is something really bizarre that is happening...let me see if I can describe it. I have a report which has two locations on it. Primary Location and Secondary Location. I have both...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.