[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 313
  • Last Modified:

Pull Multiple Values from VB datasource

I have the attached form I am creating in Visual Studio.  I am stuck at the Directory Advertising and Show Daily Advertising sections where I need to grab display the size and also get the price for that selection to calculate in the rate box.

See attached
FabtechSales.pdf
0
Albee_J
Asked:
Albee_J
  • 18
  • 15
1 Solution
 
CodeCruiserCommented:
Can you show us some code?
0
 
Albee_JAuthor Commented:
I have only begun coding the top section, I have started coding the Product Choices as I am trying to figure out the best way to handle the fact that a size is going to be pulled into a drop down list that only allows for 2 values to be extracted. The display and the Value.  The display will show the Size Name, the Value will be the Size ID, but I somehow then need to get the SizePrice based on the selected value as well.  

I will pull some fields into my project for the first product and postback here.
0
 
CodeCruiserCommented:
There are two options for doing that. Either populate a DataTable in memory and then use filtering to find the size price. Or query the database for size price given the selected size id.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
Albee_JAuthor Commented:
I am unsure of the syntax on how to do that.

Below is the code I currently have:

Partial Class Default2
    Inherits System.Web.UI.Page
    Sub Page_Load()
        Dim value As String
        If ckDirAd.Checked Then
            value = "1"
        Else
            value = ""
        End If

    End Sub

    Sub CalcMultiple()
        Const Multiple As Double = 500

        If ckMultiple.Checked = True Then txtMultipleRate.Text = FormatCurrency(Multiple)

    End Sub
    Sub CalcDirectory()
        If ckDirAd.Checked = True And ckDirSpecial.Checked = False Then
            'I forced a value in here, this really should be the Price of the Size selected the ddlDirSize
            txtDirRate.Text = 500
        ElseIf ckDirAd.Checked = True And ckDirSpecial.Checked = True Then
            txtDirRate.Text = 500 * 1.12
        ElseIf ckDirAd.Checked = False And ckDirSpecial.Checked = False Then
            txtDirRate.Text = ""
        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
            CalcMultiple()

        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
     
        End If
    End Sub

    Protected Sub ckDirAd_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ckDirAd.CheckedChanged
        CalcDirectory()
    End Sub

    Protected Sub ckDirSpecial_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ckDirSpecial.CheckedChanged
        CalcDirectory()
    End Sub
End Class
0
 
CodeCruiserCommented:
Try this code
'Page Load:
'Assuming you have populated a datatable already
 
cbxSizes.DataSource = DTable
cbxSizes.DisplayMember = "SizeName"
cbxSizes.ValueMember = "SizeID"
 
 
'combobox selectedindex changed or somewhere else.
 
Dim ID as integer = cbxSizes.SelectedValue
dTable.DefaultView.RowFilter = "SizeID=" & ID
if dTable.DefaultView.Count = 1 Then
   txtPrice.Text = dTable.DefaultView.item(0).item("SizePrice")
End If

Open in new window

0
 
Albee_JAuthor Commented:
Ah beautiful! I will implement, test and advise
0
 
Albee_JAuthor Commented:
I am getting errors here:

  ddlDirSize.DisplayMember = "OptionType"
        ddlDirSize.ValueMember = "OptionID"  

stating that  Error      1      'DisplayMember' is not a member of 'System.Web.UI.WebControls.DropDownList'.      C:\Users\jalbee\Documents\Visual Studio 2005\WebSites\FabtechSales\InsertOrders.aspx.vb      14      9      C:\...\FabtechSales\


and errors here:

    ProductSizes.DefaultView.RowFilter = "SizeID=" & ID
        If ProductSizes.DefaultView.Count = 1 Then
            txtDirRate.Text = ProductSizes.DefaultView.item(0).item("SizePrice")

stating that 'DefaultView' is not a member of 'System.Web.UI.WebControls.SqlDataSource'.      C:\Users\jalbee\Documents\Visual Studio 2005\WebSites\FabtechSales\InsertOrders.aspx.vb      23      31      C:\...\FabtechSales\

     ddlDirSize.DataSource = ProductSizes
        ddlDirSize.DisplayMember = "OptionType"
        ddlDirSize.ValueMember = "OptionID"
 
 
        'combobox selectedindex changed or somewhere else.
 
        Dim ID As Integer = ddlDirSize.SelectedValue
        ProductSizes.DefaultView.RowFilter = "SizeID=" & ID
        If ProductSizes.DefaultView.Count = 1 Then
            txtDirRate.Text = ProductSizes.DefaultView.item(0).item("SizePrice")

Open in new window

0
 
CodeCruiserCommented:
Ah ASP.NET. Change

        ddlDirSize.DisplayMember = "OptionType"
        ddlDirSize.ValueMember = "OptionID"

To

        ddlDirSize.DataTextField = "OptionType"
        ddlDirSize.DataValueField = "OptionID"


I said you need to use a DataTable not a SQLDataSource. Do this to create and populate a datatable.

Dim dTable as New DataTable
dim dbadp as new SQLDataAdapter("Select * from tablename", connectionstring)
dbadp.fill(dTable)
dbadp.dispose
Session("dTable")=dTable
'then the ddl code here

'SelectedIndex changed
dim dTable as DataTable  = Session("dTable")
If Not IsNothing(dTable) Then
   'the defaultview code here.
End If
0
 
Albee_JAuthor Commented:
The only error I a getting is here:

     'SelectedIndex changed
        Dim dTable As Data.DataTable = Session("dTable")

Error      1      Local variable 'dTable' is already declared in the current block.      C:\Users\jalbee\Documents\Visual Studio 2005\WebSites\FabtechSales\InsertOrders.aspx.vb      26      13      C:\...\FabtechSales\


Here is the full code:


        'Create data table
        Dim ConnectionString As String
        ConnectionString = "Server=FMASQL;database=HidingInformation"
        Dim dTable As New Data.DataTable
        Dim dbadp As New Data.SqlClient.SqlDataAdapter("Select * from ProductSizes", ConnectionString)
        dbadp.fill(dTable)
        dbadp.dispose()
        Session("dTable") = dTable
        'then the ddl code here
        ddlDirSize.DataSource = DTable
        ddlDirSize.DataTextField = "OptionType"
        ddlDirSize.DataValueField = "OptionID"

        'SelectedIndex changed
        Dim dTable As Data.DataTable = Session("dTable")
        If Not IsNothing(dTable) Then
            'the defaultview code here.
            Dim ID As Integer = ddlDirSize.SelectedValue
            dTable.DefaultView.RowFilter = "OptionID=" & ID
            If dTable.DefaultView.Count = 1 Then
                txtDirRate.Text = dTable.DefaultView.item(0).item("OptionPrice")
            End If
0
 
CodeCruiserCommented:
I suppose the following code is in page_load event
        'Create data table
        Dim ConnectionString As String
        ConnectionString = "Server=FMASQL;database=HidingInformation"
        Dim dTable As New Data.DataTable
        Dim dbadp As New Data.SqlClient.SqlDataAdapter("Select * from ProductSizes", ConnectionString)
        dbadp.fill(dTable)
        dbadp.dispose()
        Session("dTable") = dTable
        'then the ddl code here
        ddlDirSize.DataSource = DTable
        ddlDirSize.DataTextField = "OptionType"
        ddlDirSize.DataValueField = "OptionID"

and following is in selectedindex changed event
'SelectedIndex changed
        Dim dTable As Data.DataTable = Session("dTable")
        If Not IsNothing(dTable) Then
            'the defaultview code here.
            Dim ID As Integer = ddlDirSize.SelectedValue
            dTable.DefaultView.RowFilter = "OptionID=" & ID
            If dTable.DefaultView.Count = 1 Then
                txtDirRate.Text = dTable.DefaultView.item(0).item("OptionPrice")
            End If

Then you should not get this error but still you can change the following line
Dim dTable As Data.DataTable = Session("dTable")
to this
dTable = Session("dTable")
0
 
Albee_JAuthor Commented:
Ok, I have something wrong somewhere I am trying to assign the value to a variable and pull it in to be calculated in a subroutine CalcDirectory ()

I am getting a 0


Partial Class Default2
    Inherits System.Web.UI.Page
    Sub Page_Load()
        Dim DirValue As String
        If ckDirAd.Checked Then
            DirValue = "1"
        Else
            DirValue = ""
        End If

        'Create data table
        Dim ConnectionString As String
        ConnectionString = "Server=FMASQL;database=HidingInformation"
        Dim dTable As New Data.DataTable
        Dim dbadp As New Data.SqlClient.SqlDataAdapter("Select * from ProductSizes", ConnectionString)
        dbadp.Fill(dTable)
        dbadp.Dispose()
        Session("dTable") = dTable
        'then the ddl code here
        ddlDirSize.DataSource = DTable
        ddlDirSize.DataTextField = "OptionType"
        ddlDirSize.DataValueField = "OptionID"


    End Sub

    Sub CalcMultiple()
        Const Multiple As Double = 500

        If ckMultiple.Checked = True Then txtMultipleRate.Text = FormatCurrency(Multiple)

    End Sub
    Sub CalcDirectory()

        Dim SizePrice As Integer

        If ckDirAd.Checked = True And ckDirSpecial.Checked = False Then
            'I forced a value in here, this really should be the Price of the Size selected the ddlDirSize
            txtDirRate.Text = FormatCurrency(SizePrice)
        ElseIf ckDirAd.Checked = True And ckDirSpecial.Checked = True Then
            txtDirRate.Text = FormatCurrency(500 * 1.12)
        ElseIf ckDirAd.Checked = False And ckDirSpecial.Checked = False Then
            txtDirRate.Text = ""
        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
            CalcMultiple()

        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
     
        End If
    End Sub

    Protected Sub ckDirAd_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ckDirAd.CheckedChanged
        CalcDirectory()
    End Sub

    Protected Sub ckDirSpecial_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ckDirSpecial.CheckedChanged
        CalcDirectory()
    End Sub

    Protected Sub ddlDirSize_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ddlDirSize.SelectedIndexChanged
        CalcDirectory()
        '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")
            End If
        End If
    End Sub
End Class

0
 
CodeCruiserCommented:
After this line in selectedindexchanged
SizePrice = dTable.DefaultView.Item(0).Item("OptionPrice")
add this
Session("SizePrice") = SizePrice

then in the caldir code change this
txtDirRate.Text = FormatCurrency(SizePrice)
to this
txtDirRate.Text = FormatCurrency(Session("SizePrice"))


Remember that in ASP.NET, variables loose their values between postbacks. So we need to use Session to persist these values.
0
 
Albee_JAuthor Commented:
I added all the code and I am still gettting nothing in the txtDirRate.text box


Partial Class Default2
    Inherits System.Web.UI.Page
    Sub Page_Load()
        Dim DirValue As String
        If ckDirAd.Checked Then
            DirValue = "1"
        Else
            DirValue = ""
        End If

        'Create data table
        Dim ConnectionString As String
        ConnectionString = "Server=FMASQL;database=ProductSizes;User FMA-dbo=xxx;Password=xxx:)"
        Dim dTable As New Data.DataTable
        Dim dbadp As New Data.SqlClient.SqlDataAdapter("Select * from ProductSizes", ConnectionString)
        dbadp.Fill(dTable)
        dbadp.Dispose()
        Session("dTable") = dTable
        'then the ddl code here
        ddlDirSize.DataSource = DTable
        ddlDirSize.DataTextField = "OptionType"
        ddlDirSize.DataValueField = "OptionID"


    End Sub

    Sub CalcMultiple()
        Const Multiple As Double = 500

        If ckMultiple.Checked = True Then txtMultipleRate.Text = FormatCurrency(Multiple)

    End Sub
    Sub CalcDirectory()

        If ckDirAd.Checked = True And ckDirSpecial.Checked = False Then
            'I forced a value in here, this really should be the Price of the Size selected the ddlDirSize
            txtDirRate.Text = FormatCurrency(Session("SizePrice"))
        ElseIf ckDirAd.Checked = True And ckDirSpecial.Checked = True Then
            txtDirRate.Text = FormatCurrency(Session("SizePrice") * 1.12)
        ElseIf ckDirAd.Checked = False And ckDirSpecial.Checked = False Then
            txtDirRate.Text = ""
        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
            CalcMultiple()

        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
     
        End If
    End Sub

    Protected Sub ckDirAd_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ckDirAd.CheckedChanged
        CalcDirectory()
    End Sub

    Protected Sub ckDirSpecial_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ckDirSpecial.CheckedChanged
        CalcDirectory()
    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

            End If
        End If
        CalcDirectory()
    End Sub
End Class
0
 
Albee_JAuthor Commented:
Rut Roh can you comment out my Connection String code??
0
 
Albee_JAuthor Commented:
I think it is the connection string not working right.  

ConnectionString = "Server=FMASQL;database=ProductSizes;User ID=***;Password=***"
0
 
CodeCruiserCommented:
Step through the code and see if dTable gets any rows. Also step through and check the count of the defaultview after filtering. Or you can use some label on the page to output these values.
0
 
Albee_JAuthor Commented:
I am trying to set break points, but when I run the application it never breaks to take me back to see what has happened.
0
 
CodeCruiserCommented:
Use labels on page and set text of those labels in this code.
0
 
Albee_JAuthor Commented:
I apologize, but I do not know what you mean.
0
 
CodeCruiserCommented:
I mean put a label on the aspx page somewhere. Then within the code in page load after this line
dbadp.Fill(dTable)
use this
Label1.Text = "Table Row Count: " & dTable.Rows.Count

And in selectedindexchangedevent
after this line
dTable.DefaultView.RowFilter = "OptionID=" & ID
write
Label1.Text &= ", Filtered Count: " & dTable.DefaultView.Count
0
 
Albee_JAuthor Commented:
Ok, did that. Nothing is populating into the label at all.
0
 
CodeCruiserCommented:
Can you show the full code now? Also, does the page disappear and postback when you select some value from drop down list?
0
 
Albee_JAuthor Commented:
Yes the page does do a refresh when I select a value from the drop down list.


Partial Class Default2
    Inherits System.Web.UI.Page
    Sub Page_Load()
        Dim DirValue As String
        If ckDirAd.Checked Then
            DirValue = "1"
        Else
            DirValue = ""
        End If

        'Create data table
        Dim dTable As New Data.DataTable
        Dim dbadp As New Data.SqlClient.SqlDataAdapter("Select * from ProductSizes", "Server=FMASQL;database=ProductSizes;User ID=xxx;Password=xxx")
        dbadp.Fill(dTable)
        lblTest.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"
    End Sub

    Sub CalcMultiple()
        Const Multiple As Double = 500

        If ckMultiple.Checked = True Then txtMultipleRate.Text = FormatCurrency(Multiple)

    End Sub
    Sub CalcDirectory()

        If ckDirAd.Checked = True And ckDirSpecial.Checked = False Then
            'I forced a value in here, this really should be the Price of the Size selected the ddlDirSize
            txtDirRate.Text = FormatCurrency(Session("SizePrice"))
            'txtDirRate.Text = FormatCurrency(500)
        ElseIf ckDirAd.Checked = True And ckDirSpecial.Checked = True Then
            txtDirRate.Text = FormatCurrency(Session("SizePrice"))
            'txtDirRate.Text = FormatCurrency(500 * 1.12)
        ElseIf ckDirAd.Checked = False And ckDirSpecial.Checked = False Then
            txtDirRate.Text = ""
        End If



    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
            lblTest.Text &= ", Filtered Count: " & dTable.DefaultView.Count
            If dTable.DefaultView.Count = 1 Then
                Dim SizePrice As Integer
                SizePrice = dTable.DefaultView.Item(0).Item("OptionPrice")
                Session("SizePrice") = SizePrice

            End If
        End If
        CalcDirectory()
    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
            CalcMultiple()

        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
     
        End If
    End Sub

    Protected Sub ckDirAd_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ckDirAd.CheckedChanged
        CalcDirectory()
    End Sub

    Protected Sub ckDirSpecial_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ckDirSpecial.CheckedChanged
        CalcDirectory()
    End Sub


End Class
0
 
CodeCruiserCommented:
oh right. Put all the code in page load event in this condition

If Not Page.IsPostBack Then
'All code here
End If
0
 
Albee_JAuthor Commented:
I did that, still no dice.

    Sub Page_Load()

        Dim DirValue As String
        If ckDirAd.Checked Then
            DirValue = "1"
        Else
            DirValue = ""
        End If
        If Not Page.IsPostBack Then
            'Create data table
            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)
            lblTest.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"
        End If
    End Sub
0
 
CodeCruiserCommented:
It is really strange that lblTest does not reflect the assigned text. It means that the code is not executing. You need to play with the code to isolate the problem. For example, instead of label, use a list box and at different stages in the page, for example when the page loads or when the selectedindexchanged event is started, add items to the listbox reflect the stage at which the code is executing. This way you could follow the path of the execution. If you set breakpoint, you should be able to debug it. Make sure that this page is the startup page (right click in solution explorer on the page) and you use the play button from the toolbar and that the debug="true" in web.config.
0
 
Albee_JAuthor Commented:
I agree. I will conduct some tests and see what I  can find out. I will post back here when I do.
0
 
Albee_JAuthor Commented:
My page Load isn't even firing I have no idea why. I put a test text box to show on page load. Nothing...
0
 
CodeCruiserCommented:
Your page load event handler currently looks like this
Sub Page_Load()

But it should look like this

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
0
 
Albee_JAuthor Commented:
Ah *sigh* that is what it was.  Ok everything is working. The only problem I have now is when I choose a value in the drop down list, it does populate txtDirRate.text with the value, but the dropdownlist turns blank and is not retaining the selection...


    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        txtTest.Text = "Page Load Worked"
        If ckDirAd.Checked Then
            txtDirProdID.Text = "1"
        Else
            txtDirProdID.Text = "0"
        End If
 
        'If Not Page.IsPostBack Then
        'Create data table
        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"
        '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
            CalcMultiple()
 
        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
 
        End If
    End Sub
 
   Sub CalcDirectory()
 
        If ckDirAd.Checked = True And ckDirSpecial.Checked = False Then
            txtDirRate.Text = FormatCurrency(Session("SizePrice"))
        ElseIf ckDirAd.Checked = True And ckDirSpecial.Checked = True Then
            txtDirRate.Text = FormatCurrency(Session("SizePrice") * 1.12)
        ElseIf ckDirAd.Checked = False And ckDirSpecial.Checked = False Then
            txtDirRate.Text = ""
        End If
 
 
 
    End Sub

Open in new window

0
 
CodeCruiserCommented:
Its because you have commented out this condition

        'If Not Page.IsPostBack Then

so each time page is posted back, the list is repopulated and reset!
0
 
Albee_JAuthor Commented:
*Blush* My apologies, that was it.... Thank you sooo much for your help and patience CodeCruiser...

You REALLY helped me over a tough hurdle.
0
 
CodeCruiserCommented:
I am glad your problem is solved.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 18
  • 15
Tackle projects and never again get stuck behind a technical roadblock.
Join Now