DataGrid Totals Problem

Discussion in 'ASP .Net Web Controls' started by Rick Wiker, Apr 4, 2004.

  1. Rick Wiker

    Rick Wiker Guest

    I'm having a strange problem with totalling datagrid values

    Page contains
    Combobox with Product
    Datagri

    After selecting a product, the record is stored in a datatable that is in a session value
    The grid has a Qty field that is a bound templated textbox and a recalc button

    The totals work great when adding rows to the grid. The problem arises when I change a Qty
    and recalc the product extended price

    Sub ReCalc_Qty(ByVal sender As System.Object, ByVal e As System.EventArgs

    Dim vProdID As Integer = gdProducts.SelectedItem.Cells(0).Tex
    Dim vQtyBox As TextBox = CType(gdProducts.SelectedItem.Cells(6).FindControl("Qty"), TextBox
    Dim vQty As Integer = vQtyBox.Tex
    Dim i As Intege
    Dim vIdx As Integer, vRow As DataRow, vQtyNum As Intege
    vTBL = Session("vTblAddr"
    'How to find the ro
    Tr
    vRow = vTBL.Rows.Find(vProdID
    vRow.BeginEdit(
    vRow.Item("Qty") = CInt(vQty
    vRow.EndEdit(
    vRow.AcceptChanges(
    Session("TblAddr") = vTB
    gdProducts.DataSource = vTB
    gdProducts.DataBind(
    Catc
    Finall
    End Tr
    End Su

    Once that is done, the Product is never again included in the totals figure which are calculated in the procedure below
    All the other product records continue to add up properly, and the edited product displayes properly in the datagrid with the new prices reflected correctly

    The extended price value is a computed column in the datatable (Qty * Price)

    Hope I've made this clear. This is maddening

    Thanks in advance for any help

    Sub gdProducts_ItemDataBound(ByVal sender As Object, ByVal e As DataGridItemEventArgs
    Dim i As Intege
    Select Case e.Item.ItemTyp
    Case ListItemType.Heade
    vAddValues = "
    Case ListItemType.Item, ListItemType.AlternatingIte
    tPrice = tPrice + CDbl(e.Item.Cells(7).Text
    tMember = tMember + CDbl(e.Item.Cells(8).Text
    tMaster = tMaster + CDbl(e.Item.Cells(9).Text
    tAutoRenew = tAutoRenew + CDbl(e.Item.Cells(10).Text
    vAddValues = vAddValues & CStr(e.Item.Cells(0).Text) & ",
    Case ListItemType.Foote

    'Only perform this code if we are looking at the foote
    e.Item.Cells(1).Text = "Totals
    e.Item.Cells(1).Attributes.Add("align", "left"
    e.Item.Cells(7).Text = tPrice.ToString("c"
    e.Item.Cells(7).Attributes.Add("align", "right"
    e.Item.Cells(8).Text = tMember.ToString("c"
    e.Item.Cells(8).Attributes.Add("align", "right"
    e.Item.Cells(9).Text = tMaster.ToString("c"
    e.Item.Cells(9).Attributes.Add("align", "right"
    e.Item.Cells(10).Text = tAutoRenew.ToString("c"
    e.Item.Cells(10).Attributes.Add("align", "right"
    End Selec
    Response.Write(vAddValues & "<br>"
    End Su
     
    Rick Wiker, Apr 4, 2004
    #1
    1. Advertising

  2. Rick Wiker

    Rick Wiker Guest

    Found the problem. After updating the record, the e.Item.ItemType was SelectedItem. Had to set the selecteditem back to -1 after the edit process.
     
    Rick Wiker, Apr 7, 2004
    #2
    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. Gary
    Replies:
    4
    Views:
    1,374
    Yan-Hong Huang[MSFT]
    Feb 24, 2004
  2. Guest
    Replies:
    2
    Views:
    469
    Guest
    Jul 2, 2004
  3. =?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,655
    =?Utf-8?B?SnVzdGlu?=
    Oct 15, 2004
  4. =?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:
    890
    Alexey Smirnov
    Feb 16, 2007
  5. Lyners

    dynamic column totals datagrid

    Lyners, Aug 23, 2005, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    145
    Lyners
    Aug 23, 2005
Loading...

Share This Page