Albee_J
asked on
VB.net Rate box not clearing properly
I have a subroutine CalcDir which fires off when a checkbox called txtDirProdID is checked. My txtRate box however is not clearing to 0 like it should if the box is unchecked. My CalcSubtotal()
and CalcTotal() routines do set the txtTotal and txtSubtotal boxes to $0 if unchecked. I am sure it is something small I am missing. See the code below.
and CalcTotal() routines do set the txtTotal and txtSubtotal boxes to $0 if unchecked. I am sure it is something small I am missing. See the code below.
'On page Load
'Set value for Directory Advertising if selected
If ckDirAd.Checked Then
txtDirProdID.Text = "1"
Directory.Visible = True
Else
txtDirProdID.Text = "0"
Directory.Visible = False
txtDirColor.Text = "0"
'Subroutine
Sub CalcDirectory()
If ckDirAd.Checked = True And Val(txtDirOverride.Text) <= 0 Then
txtDirRate.Text = FormatCurrency(Session("SizePrice") + Session("SpecialPrice") + Val(txtDirColor.Text))
ElseIf ckDirAd.Checked = True And Val(txtDirOverride.Text) > 0 Then
txtDirRate.Text = FormatCurrency(Session("DirOverride"))
Else
txtDirRate.Text = "0"
End If
' Store value of txtDirRate as a Session Variable
Dim DirRate As Double
DirRate = txtDirRate.Text
Session("DirRate") = DirRate
CalcSubtotal()
End Sub
Sub CalcTotal()
If Convert.ToDateTime(lblDateRequested.Text) <= Convert.ToDateTime("7/31/2009") And txtSubtotal.Text >= 1000 And ckEarlyBird.Checked = True Then
lblEarlyBird.Text = "You qualify for the early bird special (10% Discount)"
lblEarlyBird.Visible = True
ckEarlyBird.Visible = True
txtTotal.Text = FormatCurrency(txtSubtotal.Text * 0.9)
Else
txtTotal.Text = FormatCurrency(txtSubtotal.Text)
lblEarlyBird.Visible = False
ckEarlyBird.Visible = False
End If
End Sub
Check whether you are overriding txtdir value at any other place.
ASKER
I can't find it anywhere. I will post all of this massive code to see if another set of eyes can catch it. I think I may be starring at it too long to see anything anymore *laugh*
Partial Class InsertOrders
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim rightNow As DateTime = DateTime.Now
lblDateRequested.Text = String.Format("{0:d}", rightNow)
lblUserName.Text = User.Identity.Name
'Hide Web Advertising unless Michael Scott is logged in
If User.Identity.Name = "mscott" Then
Michael.Visible = True
End If
'Set value for Directory Advertising if selected
If ckDirAd.Checked Then
txtDirProdID.Text = "1"
Directory.Visible = True
Else
txtDirProdID.Text = "0"
Directory.Visible = False
txtDirColor.Text = "0"
End If
'Set value for Enhanced Listing if selected
If ckEnhanced.Checked Then
txtEnhancedProdID.Text = "7"
Enhanced.Visible = True
Else
txtEnhancedProdID.Text = "0"
Enhanced.Visible = False
End If
'Set value for Show Daily if selected
If ckShowDaily.Checked Then
txtShowDailyProdID.Text = "2"
ShowDaily.Visible = True
Else
txtShowDailyProdID.Text = "0"
ShowDaily.Visible = False
txtShowColor.Text = "0"
End If
'Set value for Trade Show Map if selected
If ckTradeShow.Checked Then
txtTShowProdID.Text = "3"
TradeShow.Visible = True
Else
txtTShowProdID.Text = "0"
TradeShow.Visible = False
txtShowColor.Text = "0"
End If
'Set value for Floor Logos if selected
If ckFloorLogos.Checked Then
txtFloorLogosProdID.Text = "4"
FloorLogos.Visible = True
Else
txtFloorLogosProdID.Text = "0"
FloorLogos.Visible = False
txtCarpetRate.Text = "0"
End If
If Not Page.IsPostBack Then
'Create data table to grab prices for Directory Advertising Product Sizes
Dim dTable As New Data.DataTable
Dim dbadp As New Data.SqlClient.SqlDataAdapter("Select * from ProductSizes", "Data Source=FMASQL;Initial Catalog=FabtechSales;Persist Security Info=True;User ID=**;Password=**")
dbadp.Fill(dTable)
' txtTest.Text = "Table Row Count: " & dTable.Rows.Count
dbadp.Dispose()
Session("dTable") = dTable
'then the ddl code here
'ddlDirSize.DataSource = dTable
ddlDirSize.DataTextField = "OptionType"
ddlDirSize.DataValueField = "OptionID"
' Create data table to grab prices for Show Daily Product Sizes
Dim ShowTable As New Data.DataTable
Dim Showbadp As New Data.SqlClient.SqlDataAdapter("Select * from ProductSizes", "Data Source=FMASQL;Initial Catalog=FabtechSales;Persist Security Info=True;User ID=**;Password=**")
Showbadp.Fill(ShowTable)
Showbadp.Dispose()
Session("ShowTable") = ShowTable
'then the ddl code here
ddlShowSize.DataTextField = "OptionType"
ddlShowSize.DataValueField = "OptionID"
'create Data table for Directory Advertising Premium Positions
Dim sTable As New Data.DataTable
Dim sbadp As New Data.SqlClient.SqlDataAdapter("Select * from SpecialPositions", "Data Source=FMASQL;Initial Catalog=FabtechSales;Persist Security Info=True;User ID=**;Password=**")
sbadp.Fill(sTable)
sbadp.Dispose()
Session("sTable") = sTable
'then the ddl code here
ddlDirPremium.DataTextField = "Positions"
ddlDirPremium.DataValueField = "SpecialPositionID"
'create Data table for Show Daily Premium Positions
Dim DailyTable As New Data.DataTable
Dim Dailybadp As New Data.SqlClient.SqlDataAdapter("Select * from SpecialPositions", "Data Source=FMASQL;Initial Catalog=FabtechSales;Persist Security Info=True;User ID=**;Password=**")
Dailybadp.Fill(DailyTable)
Dailybadp.Dispose()
Session("DailyTable") = DailyTable
'then the ddl code here
ddlShowPrem.DataTextField = "Positions"
ddlShowPrem.DataValueField = "SpecialPositionID"
End If
End Sub
Sub CalcMultiple()
Const Multiple As Double = 500
If ckMultiple.Checked = True And Val(txtMultipleOverride.Text) <= 0 Then
txtMultipleRate.Text = FormatCurrency(Multiple)
ElseIf ckMultiple.Checked = True And Val(txtMultipleOverride.Text) > 0 Then
txtMultipleRate.Text = FormatCurrency(Session("MultipleOverride"))
Else
txtMultipleRate.Text = "0"
End If
' Store value of txtMultipleRate as a Session Variable
Dim DirMultiple As Double
DirMultiple = txtMultipleRate.Text
Session("DirMultiple") = DirMultiple
CalcSubtotal()
End Sub
Sub CalcDirectory()
If ckDirAd.Checked = True And Val(txtDirOverride.Text) <= 0 Then
txtDirRate.Text = FormatCurrency(Session("SizePrice") + Session("SpecialPrice") + Val(txtDirColor.Text))
ElseIf ckDirAd.Checked = True And Val(txtDirOverride.Text) > 0 Then
txtDirRate.Text = FormatCurrency(Session("DirOverride"))
Else
txtDirRate.Text = "0"
End If
' Store value of txtDirRate as a Session Variable
Dim DirRate As Double
DirRate = txtDirRate.Text
Session("DirRate") = DirRate
CalcSubtotal()
End Sub
Sub CalcShow()
If ckShowDaily.Checked = True And Val(txtShowOverride.Text) <= 0 Then
txtShowRate.Text = FormatCurrency(Session("ShowSize") + Session("ShowPremPrice") + Val(txtShowColor.Text))
ElseIf ckShowDaily.Checked = True And Val(txtShowOverride.Text) > 0 Then
txtShowRate.Text = FormatCurrency(Session("ShowOverride"))
Else
txtShowRate.Text = "0"
End If
' Store value of txtShowRate as a Session Variable
Dim ShowRate As Double
ShowRate = txtShowRate.Text
Session("ShowRate") = ShowRate
CalcSubtotal()
End Sub
Sub CalcEnhanced()
If ckEnhanced.Checked = True And Val(txtEnhRateOverride.Text) <= 0 Then
txtEnhancedRate.Text = FormatCurrency(Val(txtWebLevel.Text))
ElseIf ckEnhanced.Checked = True And Val(txtEnhRateOverride.Text) > 0 Then
txtEnhancedRate.Text = FormatCurrency(Session("EnhancedOverride"))
Else
txtEnhancedRate.Text = "0"
End If
' Store value of txtEnhancedRate as a Session Variable
Dim EnhancedRate As Double
EnhancedRate = txtEnhancedRate.Text
Session("EnhancedRate") = EnhancedRate
CalcSubtotal()
End Sub
Sub CalcTrade()
If ckTradeShow.Checked = True And Val(txtTradeOverride.Text) <= 0 Then
txtTradeRate.Text = FormatCurrency(Val(txtBCRate.Text) + Val(txtBackCoverRate.Text))
ElseIf ckTradeShow.Checked = True And Val(txtTradeOverride.Text) > 0 Then
txtTradeRate.Text = FormatCurrency(Session("TradeOverride"))
Else
txtTradeRate.Text = "0"
End If
' Store value of txtEnhancedRate as a Session Variable
Dim TradeRate As Double
TradeRate = txtTradeRate.Text
Session("TradeRate") = TradeRate
CalcSubtotal()
End Sub
Sub CalcFloorLogos()
If ckFloorLogos.Checked = True And Val(txtFloorOverride.Text) <= 0 Then
txtFloorRate.Text = FormatCurrency(Val(txtCarpetRate.Text))
ElseIf ckFloorLogos.Checked = True And Val(txtFloorOverride.Text) > 0 Then
txtFloorRate.Text = FormatCurrency(Session("FloorOverride"))
Else
txtFloorRate.Text = "0"
End If
' Store value of txtEnhancedRate as a Session Variable
Dim FloorRate As Double
FloorRate = txtFloorRate.Text
Session("FloorRate") = FloorRate
CalcSubtotal()
End Sub
Sub CalcSubtotal()
txtSubtotal.Text = FormatCurrency(Session("DirRate") + Session("DirMultiple") + Session("EnhancedRate") + Session("ShowRate") + Session("TradeRate") + Session("FloorLogos"))
CalcTotal()
End Sub
Sub CalcTotal()
If Convert.ToDateTime(lblDateRequested.Text) <= Convert.ToDateTime("7/31/2009") And txtSubtotal.Text >= 1000 And ckEarlyBird.Checked = True Then
lblEarlyBird.Text = "You qualify for the early bird special (10% Discount)"
lblEarlyBird.Visible = True
ckEarlyBird.Visible = True
txtTotal.Text = FormatCurrency(txtSubtotal.Text * 0.9)
Else
txtTotal.Text = FormatCurrency(txtSubtotal.Text)
lblEarlyBird.Visible = False
ckEarlyBird.Visible = False
End If
End Sub
Protected Sub txtMultiple_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ckMultiple.CheckedChanged
If ckMultiple.Checked = True Then
lblSecondary.Text = "Secondary Company Name:"
lblSecondary.ToolTip = "Enter in Secondary company name as it is to be shown in directory/web"
lblMultipleIn.Visible = True
ckMultipleIn.Visible = True
lblMultipleRate.Visible = True
txtMultipleRate.Visible = True
lblMultipleOverride.Visible = True
txtMultipleOverride.Visible = True
Else
lblSecondary.Text = "Other Advertiser:"
lblSecondary.ToolTip = "Not Exhibiting or sharing a booth, list company name"
lblMultipleIn.Visible = False
ckMultipleIn.Visible = False
lblMultipleRate.Visible = False
txtMultipleRate.Visible = False
lblMultipleOverride.Visible = False
txtMultipleOverride.Visible = False
End If
CalcMultiple()
End Sub
Protected Sub ddlDirSize_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ddlDirSize.SelectedIndexChanged
'SelectedIndex changed
Dim dTable As Data.DataTable = Session("dTable")
If Not IsNothing(dTable) Then
Dim ID As Integer = ddlDirSize.SelectedValue
dTable.DefaultView.RowFilter = "OptionID=" & ID
If dTable.DefaultView.Count = 1 Then
Dim SizePrice As Integer
SizePrice = dTable.DefaultView.Item(0).Item("OptionPrice")
Session("SizePrice") = SizePrice
txtDirSizePrice.Text = "Rate:" & " " & FormatCurrency(Session("SizePrice"))
End If
End If
CalcDirectory()
End Sub
Protected Sub ddlDirPremium_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ddlDirPremium.SelectedIndexChanged
'SelectedIndex changed
Dim sTable As Data.DataTable = Session("sTable")
If Not IsNothing(sTable) Then
Dim ID As Integer = ddlDirPremium.SelectedValue
sTable.DefaultView.RowFilter = "SpecialPositionID=" & ID
If sTable.DefaultView.Count = 1 Then
Dim SpecialPrice As Integer
SpecialPrice = sTable.DefaultView.Item(0).Item("PositionPrice")
Session("SpecialPrice") = SpecialPrice
txtDirPremPrice.Text = "Rate:" & " " & FormatCurrency(Session("SpecialPrice"))
End If
End If
CalcDirectory()
End Sub
Protected Sub ckDirAd_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ckDirAd.CheckedChanged
CalcDirectory()
End Sub
Protected Sub rdDirColor_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles rdDirColor.SelectedIndexChanged
If Page.IsPostBack Then
If rdDirColor.SelectedItem.Value = "2 color" Then
txtDirColor.Text = "400"
ElseIf rdDirColor.SelectedItem.Value = "4 color" Then
txtDirColor.Text = "900"
Else
txtDirColor.Text = "0"
End If
End If
CalcDirectory()
End Sub
Protected Sub txtDirOverride_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtDirOverride.TextChanged
Dim DirOverride As Integer
DirOverride = Val(txtDirOverride.Text)
Session("DirOverride") = DirOverride
CalcDirectory()
End Sub
Protected Sub rdWebLevel_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles rdWebLevel.SelectedIndexChanged
If Page.IsPostBack Then
If rdWebLevel.SelectedItem.Value = "Classic " Then
txtWebLevel.Text = "500"
ElseIf rdWebLevel.SelectedItem.Value = "Premium " Then
txtWebLevel.Text = "750"
ElseIf rdWebLevel.SelectedItem.Value = "Ultra" Then
txtWebLevel.Text = "1700"
Else
txtWebLevel.Text = "0"
End If
End If
CalcEnhanced()
End Sub
Protected Sub txtEnhRateOverride_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtEnhRateOverride.TextChanged
Dim EnhancedOverride As Integer
EnhancedOverride = Val(txtEnhRateOverride.Text)
Session("EnhancedOverride") = EnhancedOverride
CalcEnhanced()
End Sub
Protected Sub ddlShowSize_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ddlShowSize.SelectedIndexChanged
'SelectedIndex changed
Dim ShowTable As Data.DataTable = Session("ShowTable")
If Not IsNothing(ShowTable) Then
Dim ID As Integer = ddlShowSize.SelectedValue
ShowTable.DefaultView.RowFilter = "OptionID=" & ID
If ShowTable.DefaultView.Count = 1 Then
Dim ShowSize As Integer
ShowSize = ShowTable.DefaultView.Item(0).Item("OptionPrice")
Session("ShowSize") = ShowSize
txtShowSizePrice.Text = "Rate:" & " " & FormatCurrency(Session("ShowSize"))
End If
End If
CalcShow()
End Sub
Protected Sub ddlShowPrem_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ddlShowPrem.SelectedIndexChanged
'SelectedIndex changed
Dim DailyTable As Data.DataTable = Session("DailyTable")
If Not IsNothing(DailyTable) Then
Dim ID As Integer = ddlShowPrem.SelectedValue
DailyTable.DefaultView.RowFilter = "SpecialPositionID=" & ID
If DailyTable.DefaultView.Count = 1 Then
Dim ShowPremPrice As Integer
ShowPremPrice = DailyTable.DefaultView.Item(0).Item("PositionPrice")
Session("ShowPremPrice") = ShowPremPrice
txtShowPremPrice.Text = "Rate:" & " " & FormatCurrency(Session("ShowPremPrice"))
End If
End If
CalcShow()
End Sub
Protected Sub rdShowColors_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles rdShowColors.SelectedIndexChanged
If Page.IsPostBack Then
If rdShowColors.SelectedItem.Value = "2 color" Then
txtShowColor.Text = "400"
ElseIf rdShowColors.SelectedItem.Value = "4 color" Then
txtShowColor.Text = "900"
Else
txtShowColor.Text = "0"
End If
End If
CalcShow()
End Sub
Protected Sub ckShowDaily_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ckShowDaily.CheckedChanged
CalcShow()
End Sub
Protected Sub txtShowOverride_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtShowOverride.TextChanged
Dim ShowOverride As Integer
ShowOverride = Val(txtShowOverride.Text)
Session("ShowOverride") = ShowOverride
CalcShow()
End Sub
Protected Sub ckEarlyBird_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ckEarlyBird.CheckedChanged
CalcTotal()
End Sub
Protected Sub ckBusinessCard_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ckBusinessCard.CheckedChanged
If ckBusinessCard.Checked = True Then
txtBCRate.Text = "1995"
Else
txtBCRate.Text = "0"
End If
CalcTrade()
End Sub
Protected Sub ckBackCover_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ckBackCover.CheckedChanged
If ckBackCover.Checked = True Then
txtBackCoverRate.Text = "4995"
Else
txtBackCoverRate.Text = "0"
End If
CalcTrade()
End Sub
Protected Sub txtTradeOverride_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtTradeOverride.TextChanged
Dim TradeOverride As Integer
TradeOverride = Val(txtTradeOverride.Text)
Session("TradeOverride") = TradeOverride
CalcTrade()
End Sub
Protected Sub txtMultipleOverride_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtMultipleOverride.TextChanged
Dim MultipleOverride As Integer
MultipleOverride = Val(txtMultipleOverride.Text)
Session("MultipleOverride") = MultipleOverride
CalcMultiple()
End Sub
Protected Sub ckCarpetOverlays_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ckCarpetOverlays.CheckedChanged
If ckCarpetOverlays.Checked = True Then
txtCarpetRate.Text = "2000"
Else
txtCarpetRate.Text = "0"
End If
CalcFloorLogos()
End Sub
Protected Sub txtFloorOverride_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtFloorOverride.TextChanged
Dim FloorOverride As Integer
FloorOverride = Val(txtFloorOverride.Text)
Session("FloorOverride") = FloorOverride
CalcFloorLogos()
End Sub
Protected Sub ckEnhanced_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ckEnhanced.CheckedChanged
CalcEnhanced()
End Sub
Protected Sub ckTradeShow_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ckTradeShow.CheckedChanged
CalcTrade()
End Sub
Protected Sub ckFloorLogos_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ckFloorLogos.CheckedChanged
CalcFloorLogos()
End Sub
End Class
Iam looking at the code mean while can u debug step by step and look into textbox value
ASKER
Yes, I will see if I can get the break and step by step to work. Last time I tried on this application it wouldn't debug properly even though I have it set to debug.
Hit F11 to move into functions too so we can notice changes inside the funcs
Do you mean that txtDirRate does not change to 0 in the else part of this code
If ckDirAd.Checked = True And Val(txtDirOverride.Text) <= 0 Then
txtDirRate.Text = FormatCurrency(Session("Si zePrice") + Session("SpecialPrice") + Val(txtDirColor.Text))
ElseIf ckDirAd.Checked = True And Val(txtDirOverride.Text) > 0 Then
txtDirRate.Text = FormatCurrency(Session("Di rOverride" ))
Else
txtDirRate.Text = "0"
End If
?
If ckDirAd.Checked = True And Val(txtDirOverride.Text) <= 0 Then
txtDirRate.Text = FormatCurrency(Session("Si
ElseIf ckDirAd.Checked = True And Val(txtDirOverride.Text) > 0 Then
txtDirRate.Text = FormatCurrency(Session("Di
Else
txtDirRate.Text = "0"
End If
?
ASKER
I tried, I set a Breakpoint and it never breaks... I hit F11 fires off the application, never breaks.
ASKER
I would think this has to be working
Else
txtDirRate.Text = "0"
End If
' Store value of txtDirRate as a Session Variable
Dim DirRate As Double
DirRate = txtDirRate.Text
Session("DirRate") = DirRate
CalcSubtotal()
because the CalcSubtotal() resets to 0 when I uncheck the box.
In the checkbox it has this code
Protected Sub ckDirAd_CheckedChanged(ByV al sender As Object, ByVal e As System.EventArgs) Handles ckDirAd.CheckedChanged
CalcDirectory()
End Sub
Else
txtDirRate.Text = "0"
End If
' Store value of txtDirRate as a Session Variable
Dim DirRate As Double
DirRate = txtDirRate.Text
Session("DirRate") = DirRate
CalcSubtotal()
because the CalcSubtotal() resets to 0 when I uncheck the box.
In the checkbox it has this code
Protected Sub ckDirAd_CheckedChanged(ByV
CalcDirectory()
End Sub
Try this
Sub CalcDirectory()
txtDirRate.Focus()
If ckDirAd.Checked = True And Val(txtDirOverride.Text) <= 0 Then
txtDirRate.Text = FormatCurrency(Session("Si zePrice") + Session("SpecialPrice") + Val(txtDirColor.Text))
ElseIf ckDirAd.Checked = True And Val(txtDirOverride.Text) > 0 Then
txtDirRate.Text = FormatCurrency(Session("Di rOverride" ))
Else
txtDirRate.Text = "0"
End If
' Store value of txtDirRate as a Session Variable
Dim DirRate As Double
DirRate = txtDirRate.Text
Session("DirRate") = DirRate
CalcSubtotal()
End Sub
Sub CalcDirectory()
txtDirRate.Focus()
If ckDirAd.Checked = True And Val(txtDirOverride.Text) <= 0 Then
txtDirRate.Text = FormatCurrency(Session("Si
ElseIf ckDirAd.Checked = True And Val(txtDirOverride.Text) > 0 Then
txtDirRate.Text = FormatCurrency(Session("Di
Else
txtDirRate.Text = "0"
End If
' Store value of txtDirRate as a Session Variable
Dim DirRate As Double
DirRate = txtDirRate.Text
Session("DirRate") = DirRate
CalcSubtotal()
End Sub
ASKER
Will do srikanthreddyn143. I will test and post back
ASKER
txtDirRate.Focus() didn't make any difference. The txtDirRate.Text box is still retaining its value after I uncheck the box.
Your use of Session suggests that its a web application. Have you set the AutoPostback property of the checkbox to true?
ASKER
Yes. I think I may have narrowed the problem down.
In the Directory area there is a dropdown list that I am populating with a data table. It is this value that the textbox is holding onto even though the ddl looks to be set to the 'none' option on refresh.
Protected Sub ddlDirSize_SelectedIndexCh anged(ByVa l sender As Object, ByVal e As System.EventArgs) Handles ddlDirSize.SelectedIndexCh anged
'SelectedIndex changed
Dim dTable As Data.DataTable = Session("dTable")
If Not IsNothing(dTable) Then
Dim ID As Integer = ddlDirSize.SelectedValue
dTable.DefaultView.RowFilt er = "OptionID=" & ID
If dTable.DefaultView.Count = 1 Then
Dim SizePrice As Integer
SizePrice = dTable.DefaultView.Item(0) .Item("Opt ionPrice")
Session("SizePrice") = SizePrice
txtDirSizePrice.Text = "Rate:" & " " & FormatCurrency(Session("Si zePrice"))
End If
End If
CalcDirectory()
In the Directory area there is a dropdown list that I am populating with a data table. It is this value that the textbox is holding onto even though the ddl looks to be set to the 'none' option on refresh.
Protected Sub ddlDirSize_SelectedIndexCh
'SelectedIndex changed
Dim dTable As Data.DataTable = Session("dTable")
If Not IsNothing(dTable) Then
Dim ID As Integer = ddlDirSize.SelectedValue
dTable.DefaultView.RowFilt
If dTable.DefaultView.Count = 1 Then
Dim SizePrice As Integer
SizePrice = dTable.DefaultView.Item(0)
Session("SizePrice") = SizePrice
txtDirSizePrice.Text = "Rate:" & " " & FormatCurrency(Session("Si
End If
End If
CalcDirectory()
Now i am confused. You problem is that the txtDirRate is not being set to 0 in the if condition here
If ckDirAd.Checked = True And Val(txtDirOverride.Text) <= 0 Then
txtDirRate.Text = FormatCurrency(Session("Si zePrice") + Session("SpecialPrice") + Val(txtDirColor.Text))
ElseIf ckDirAd.Checked = True And Val(txtDirOverride.Text) > 0 Then
txtDirRate.Text = FormatCurrency(Session("Di rOverride" ))
Else
txtDirRate.Text = "0"
End If
Is that correct? If not please explain in functional terms which line of code you have problem with.
If ckDirAd.Checked = True And Val(txtDirOverride.Text) <= 0 Then
txtDirRate.Text = FormatCurrency(Session("Si
ElseIf ckDirAd.Checked = True And Val(txtDirOverride.Text) > 0 Then
txtDirRate.Text = FormatCurrency(Session("Di
Else
txtDirRate.Text = "0"
End If
Is that correct? If not please explain in functional terms which line of code you have problem with.
ASKER
Sorry.
Ok. The problem lies if I select a value in the drop down list. ddlDirSize which is part of the CalcDirectory() Subroutine. (Session("SizePrice")
If I uncheck the box which fires off the CalcDirectory() Subroutine the txtDirRate.Text = "0" is not really showing. It is still holding the value of (Session("SizePrice") not matter what.
Ok. The problem lies if I select a value in the drop down list. ddlDirSize which is part of the CalcDirectory() Subroutine. (Session("SizePrice")
If I uncheck the box which fires off the CalcDirectory() Subroutine the txtDirRate.Text = "0" is not really showing. It is still holding the value of (Session("SizePrice") not matter what.
ASKER
I figure it out!
On page load I added this Session.Clear() to the code below.
'Set value for Directory Advertising if selected
If ckDirAd.Checked Then
txtDirProdID.Text = "1"
Directory.Visible = True
Else
txtDirProdID.Text = "0"
Directory.Visible = False
txtDirColor.Text = "0"
Session.Clear()
On page load I added this Session.Clear() to the code below.
'Set value for Directory Advertising if selected
If ckDirAd.Checked Then
txtDirProdID.Text = "1"
Directory.Visible = True
Else
txtDirProdID.Text = "0"
Directory.Visible = False
txtDirColor.Text = "0"
Session.Clear()
ASKER
crap I spoke to soon that clears too much LOL
My question again is "is the autopostback set to true on checkbox" or in more plain terms "does the page postback when you tick or untick the checkbox?"
ASKER
Yes it does. The autopostback function on the checkbox is set to true. The value from the dropdown list which is stored as a variable is not clearing.
I think I may have figured it out again..
Session.Remove("SizePrice" )
I think I may have figured it out again..
Session.Remove("SizePrice"
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Hmm. So it means wrong condition is being met in your calcdir method! I think the problem is this if condition
Val(txtDirOverride.Text) <= 0
Try changing this to
Val(txtDirOverride.Text) = 0
Val(txtDirOverride.Text) <= 0
Try changing this to
Val(txtDirOverride.Text) = 0
Any have the checkbox is unchecked, that makes the if condition false and goes to txtdirrate.text = "0". Am I Right?
ASKER
ah k lemme try that.
ASKER
CodeCruiser: That didn't work. the textbox still has the drop down list rate in it.
ASKER
srikanthreddyn143,
Yes that is what it is supposed to do.
Yes that is what it is supposed to do.
ASKER
This is on page load
-------------------------- ---
'Set value for Show Daily if selected
If ckShowDaily.Checked Then
txtShowDailyProdID.Text = "2"
ShowDaily.Visible = True
Else
txtShowDailyProdID.Text = "0"
ShowDaily.Visible = False
txtShowColor.Text = "0"
Session.Remove("ShowSize")
Session.Remove("ShowPremPr ice")
End If
-------------------------- ----
This also fired when the checkbox is checked
Sub CalcDirectory()
txtDirRate.Focus()
If ckDirAd.Checked = True And Val(txtDirOverride.Text) <= 0 Then
txtDirRate.Text = FormatCurrency(Session("Si zePrice") + Session("SpecialPrice") + Val(txtDirColor.Text))
ElseIf ckDirAd.Checked = True And Val(txtDirOverride.Text) > 0 Then
txtDirRate.Text = FormatCurrency(Session("Di rOverride" ))
Else
txtDirRate.Text = "0"
txtDirOverride.Text = "0"
End If
' Store value of txtDirRate as a Session Variable
Dim DirRate As Double
DirRate = txtDirRate.Text
Session("DirRate") = DirRate
CalcSubtotal()
End Sub
--------------------------
'Set value for Show Daily if selected
If ckShowDaily.Checked Then
txtShowDailyProdID.Text = "2"
ShowDaily.Visible = True
Else
txtShowDailyProdID.Text = "0"
ShowDaily.Visible = False
txtShowColor.Text = "0"
Session.Remove("ShowSize")
Session.Remove("ShowPremPr
End If
--------------------------
This also fired when the checkbox is checked
Sub CalcDirectory()
txtDirRate.Focus()
If ckDirAd.Checked = True And Val(txtDirOverride.Text) <= 0 Then
txtDirRate.Text = FormatCurrency(Session("Si
ElseIf ckDirAd.Checked = True And Val(txtDirOverride.Text) > 0 Then
txtDirRate.Text = FormatCurrency(Session("Di
Else
txtDirRate.Text = "0"
txtDirOverride.Text = "0"
End If
' Store value of txtDirRate as a Session Variable
Dim DirRate As Double
DirRate = txtDirRate.Text
Session("DirRate") = DirRate
CalcSubtotal()
End Sub
@srikanthreddyn143
True. I overlooked.
Anyway, the problem is solved now by removing the session value on load.
True. I overlooked.
Anyway, the problem is solved now by removing the session value on load.