Button only allows one click
-
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 -
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. thanksYou 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 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
-
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