Error trying to get totals in footer

Discussion in 'ASP .Net' started by Guest, Jun 29, 2004.

  1. Guest

    Guest 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
    Guest, Jun 29, 2004
    #1
    1. Advertising

  2. 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!
    ************************************************
    <> wrote in message
    news:...
    > 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
    >
    >
    >
    Cowboy \(Gregory A. Beamer\) [MVP], Jun 30, 2004
    #2
    1. Advertising

  3. Guest

    Guest Guest

    Greg:

    Thanks for the response.

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


    SC

    "Cowboy (Gregory A. Beamer) [MVP]" <> wrote
    in message news:...
    > 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!
    > ************************************************
    > <> wrote in message
    > news:...
    > > 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
    > >
    > >
    > >

    >
    >
    Guest, Jul 2, 2004
    #3
    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. mark

    footer totals

    mark, Sep 7, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    466
    Greg Burns
    Sep 7, 2004
  2. =?Utf-8?B?SnVzdGlu?=

    Showing datagrid totals in the footer

    =?Utf-8?B?SnVzdGlu?=, Oct 14, 2004, in forum: ASP .Net
    Replies:
    9
    Views:
    4,558
    =?Utf-8?B?SnVzdGlu?=
    Oct 15, 2004
  3. =?Utf-8?B?Um9iZXJ0IENoYXBtYW4=?=

    Running totals in gridview (when you have many totals required)

    =?Utf-8?B?Um9iZXJ0IENoYXBtYW4=?=, Feb 15, 2007, in forum: ASP .Net
    Replies:
    3
    Views:
    843
    Alexey Smirnov
    Feb 16, 2007
  4. SStory

    Totals in grid footer?

    SStory, May 11, 2004, in forum: ASP .Net Datagrid Control
    Replies:
    3
    Views:
    151
    Saravana [MVP]
    May 14, 2004
  5. RockNRoll

    NEWBIE - Column Totals in Footer of mxDataGrid

    RockNRoll, Aug 12, 2004, in forum: ASP .Net Datagrid Control
    Replies:
    3
    Views:
    138
    Alvin Bruney [MVP]
    Aug 13, 2004
Loading...

Share This Page