Solved

Pull Multiple Values from VB datasource

Posted on 2009-05-05
33
264 Views
Last Modified: 2012-05-06
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
Comment
Question by:Albee_J
  • 18
  • 15
33 Comments
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 24314649
Can you show us some code?
0
 

Author Comment

by:Albee_J
ID: 24314740
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
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 24314824
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
 

Author Comment

by:Albee_J
ID: 24315547
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
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 24315757
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
 

Author Comment

by:Albee_J
ID: 24315814
Ah beautiful! I will implement, test and advise
0
 

Author Comment

by:Albee_J
ID: 24315919
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
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 24316010
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
 

Author Comment

by:Albee_J
ID: 24316238
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
 
LVL 83

Accepted Solution

by:
CodeCruiser earned 500 total points
ID: 24316392
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
 

Author Comment

by:Albee_J
ID: 24316684
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
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 24316722
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
 

Author Comment

by:Albee_J
ID: 24316891
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
 

Author Comment

by:Albee_J
ID: 24316909
Rut Roh can you comment out my Connection String code??
0
 

Author Comment

by:Albee_J
ID: 24317162
I think it is the connection string not working right.  

ConnectionString = "Server=FMASQL;database=ProductSizes;User ID=***;Password=***"
0
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 24317470
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:Albee_J
ID: 24317520
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
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 24317575
Use labels on page and set text of those labels in this code.
0
 

Author Comment

by:Albee_J
ID: 24317618
I apologize, but I do not know what you mean.
0
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 24317675
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
 

Author Comment

by:Albee_J
ID: 24317795
Ok, did that. Nothing is populating into the label at all.
0
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 24317811
Can you show the full code now? Also, does the page disappear and postback when you select some value from drop down list?
0
 

Author Comment

by:Albee_J
ID: 24317865
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
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 24317916
oh right. Put all the code in page load event in this condition

If Not Page.IsPostBack Then
'All code here
End If
0
 

Author Comment

by:Albee_J
ID: 24319122
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
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 24319253
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
 

Author Comment

by:Albee_J
ID: 24325573
I agree. I will conduct some tests and see what I  can find out. I will post back here when I do.
0
 

Author Comment

by:Albee_J
ID: 24326068
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
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 24326223
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
 

Author Comment

by:Albee_J
ID: 24326782
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
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 24326842
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
 

Author Comment

by:Albee_J
ID: 24326873
*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
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 24327034
I am glad your problem is solved.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Need to grow your business through quality cloud solutions? With everything required to build a cloud platform and solution, you may feel like the distance between you and the cloud is quite long. Help is here. Spend some time learning about the Con…
A simple description of email encryption using a secure portal service. This is one of the choices offered by The Email Laundry for email encryption. The other choices are pdf encryption which creates an encrypted pdf of your email and any attachmen…

914 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now