R
Rick Wiker
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
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