Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Button only allows one click

Button only allows one click

Scheduled Pinned Locked Moved ASP.NET
databasehelp
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    jamesbronw
    wrote on last edited by
    #1

    Ok i have a button on my webform. When i click it it is suppose to open a database and read from it. It does this and returns the first value into a text box. Now when i click it again i want it to return the second value of that database, but it does not, the text box stays showing the value of the first click. Here is my code Private Sub btnnext_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnnext.Click createreader(sql) myreader.Read() descrip.Text = myreader.GetValue(0) Page.Response.Write(descrip.Text) End Sub Please any help would be much welcomed. thanks

    A 1 Reply Last reply
    0
    • J jamesbronw

      Ok i have a button on my webform. When i click it it is suppose to open a database and read from it. It does this and returns the first value into a text box. Now when i click it again i want it to return the second value of that database, but it does not, the text box stays showing the value of the first click. Here is my code Private Sub btnnext_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnnext.Click createreader(sql) myreader.Read() descrip.Text = myreader.GetValue(0) Page.Response.Write(descrip.Text) End Sub Please any help would be much welcomed. thanks

      A Offline
      A Offline
      Alvaro Mendez
      wrote on last edited by
      #2

      You need to keep track of which value to read next. From your code, I don't see how you're doing that. In the old days you would do it using a hidden input field (or the Session - yuck). These days you can use the ViewState property. Regards, Alvaro


      You know what they say about arguing over the Internet...

      A 1 Reply Last reply
      0
      • A Alvaro Mendez

        You need to keep track of which value to read next. From your code, I don't see how you're doing that. In the old days you would do it using a hidden input field (or the Session - yuck). These days you can use the ViewState property. Regards, Alvaro


        You know what they say about arguing over the Internet...

        A Offline
        A Offline
        Anonymous
        wrote on last edited by
        #3

        How would i go about using the viewstate? i have never heard of it would you be able to show me a snippet of code or point me to where i could find one? Thanks Tommy

        A 1 Reply Last reply
        0
        • A Anonymous

          How would i go about using the viewstate? i have never heard of it would you be able to show me a snippet of code or point me to where i could find one? Thanks Tommy

          A Offline
          A Offline
          Alvaro Mendez
          wrote on last edited by
          #4

          Read the documentation.[^] Regards, Alvaro


          You know what they say about arguing over the Internet...

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups