Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8349957
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T08:10:03+00:00 2026-06-09T08:10:03+00:00

I am having an odd accuence when i am trying to get my page

  • 0

I am having an odd accuence when i am trying to get my page loaded value to place into a database after the user submits.

When the page loads i have this:

Public theProductName As String = ""
Dim theProductCategory As String = ""

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    If Not IsPostBack Then
        LoadProductName()
    End If
End Sub

Private Sub LoadProductName()
    objConn = New MySqlConnection(product.strConnString)
    objConn.Open()

    strSQL = "SELECT id, name, category " & _
                "FROM product " & _
                "WHERE id = 4;"

    Try
        objCmd = New MySqlCommand(strSQL, objConn)
        dtReader = objCmd.ExecuteReader()

        While dtReader.Read()
            theProductName = dtReader("name")
            theProductCategory = dtReader("category")
            btnSubmit.Text = "Add Item to " & theProductName
        End While

        dtReader.Close()
        dtReader = Nothing
        objConn.Close()
        objConn = Nothing
    Catch ex As Exception
        MsgBox("LoadProductName: " & ex.Message)
    End Try
End Sub

When i check those values on startup of the page they have the correct values and even the submit button has the products name.

However, once i got to save it after pushing the button it has that same variable as nothing??

Private Sub btnSubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSubmit.Click

   Dim productName As String = theProductName.Replace(" ", "-")
   Dim imageName As String = productName & "\" & Trim(txtModel.Text) & ".jpg'"       
   Dim theCat as String = theProductCategory
End Sub

productName here is nothing as is theCat

What could i be overlooking?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T08:10:05+00:00Added an answer on June 9, 2026 at 8:10 am

    You must to persist your data with ViewState.because you post your data so you lost your old state

    public string ProductName 
    {
      get
      {
          if( Viewstate["ProductName"] == null)
          {
             return string.Empty;
          }
          return (string)Viewstate["ProductName"];
       } 
      set
      {
         Viewstate["ProductName"] = value;
      }
    }
    

    Set the value

    ProductName = "your value";
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am having a really odd problem trying to set a simple float value
Im having a very odd problem. Im trying to install a Python program. Im
I am having an odd problem deleting rows from a sqlite database. The first
I am having this odd error with my code. I am trying to troubleshoot
I'm having an odd problem. My controller is trying to call uri segments and
I'm having an odd problem, I can't get an object from the DB and
I'm having this odd problem where I can store an email test@gmail.com into my
I've been having some odd problems with permission in Android. I am trying to
On a test page I'm building I'm having this odd spacing appear at the
I'm having an odd issue happen when trying to position an SVG at the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.