Results 1 to 2 of 2

Thread: how to retrieve data from a session table

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Dec 2009
    Posts
    18

    how to retrieve data from a session table

    I developing an invoice page where user will select Product from a combo box (approx. 500 + item). I am loading product Name, Product ID, sales price in a session Table. After selecting the product, a textbox value will Sales Price. But it is taking so much time.

    On page load event:
    Code:
                    PBProductID.DataSource = Session("TableProductAll")
                    PBProductID.DataBind()
    Session("TableProductAll") is filled when user first login to the system in the login page
    On PBProductID_SelectedIndexChanged event:

    Code:
      Dim strCriteria As String = ""
      PBSalesPrice.Text = 0
      strCriteria = " ProductID = '" & PBProductID.Text & "'"
      Dim SearchRow As DataRow() = Session"TableProductAll").Select(strCriteria)
      If SearchRow.Count > 0 Then PBSalesPrice.Text = SearchRow(0)   ("pPriceSales").ToString
    How to reduce the time at PBProductID_SelectedIndexChanged event (at present it taking apprx. 45 sec or more)
    Looking for a better solution of way to fill a combo box and retrieve sales price from that table after selecting the product ID.
    Last edited by mazez1971; Sep 25th, 2011 at 11:06 PM.

  2. #2
    PowerPoster stanav's Avatar
    Join Date
    Jul 2006
    Location
    Providence, RI - USA
    Posts
    9,290

    Re: how to retrieve data from a session table

    1. Turn Option Strict ON and fix any errors resulted from this.

    2. You should load the product table once on 1st page load and don't load it again for sub-sequencen page loads. To control this, you test the Page.IsPostBack property
    Code:
    If Not Page.IsPostBack Then
       'Load you product table data here
       '
       'Then save that to a session variable
       Session("TableProductAll") = theProductTable
    End If
    'Now bind that productTable to your control
    Dim productTable as DataTable = DirectCast(Session("TableProductAll"), DataTable)
    PBProductID.DataSource = productTable
    PBProductID.DataBind()
    On PBProductID_SelectedIndexChanged event:
    Code:
      Dim strCriteria As String = ""
      PBSalesPrice.Text = 0
      strCriteria = " ProductID = '" & PBProductID.Text & "'"
      Dim productTable As DataTable = DirectCast(Session("TableProductAll"), DataTable)
      Dim SearchRow As DataRow() = productTable.Select(strCriteria)
      If SearchRow.Count > 0 Then PBSalesPrice.Text = SearchRow(0)("pPriceSales").ToString
    Let us have faith that right makes might, and in that faith, let us, to the end, dare to do our duty as we understand it.
    - Abraham Lincoln -

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width