Bass:
I think the problem is as simple as not specifying the CurrentQuestion on
postback.
When you postback, you recreate the control via your call to
GetQuestion(SurveyNum, CurrentQuestion) in the ELSE of the page_load...but
CurrentQuestion isn't initialized hence it's passing in 0. That can be my
only guess.
A couple side notes, turning option strict on in vb.net would be greatly
beneficial for you, although difficult at first. Can't find a link right
now...but if you right-click the project in VS.Net it'll be an option there
(somewhere).
Also, how you ge the data could be made much more efficient. I take it your
stpr_MasterData gets all the questions, which you loop through to get a
total count, and make sure the current question is always the first. It's
inneficient because (a) you are returning all questions (even though you
only need the first) and (b) you are hitting the DB multiple times.
2 ways to solve this...
use a datatable and cache it (i'll let you explore this on your own)
make your sproc return 2 result sets
create procedure stpr_MasterData
@CurrentQuestion INT
AS
BEGIn
SELECT Count(*) from MyQuestions
-- sELECT * sucks, but just for a demo...
SELECT * FROM MyQuestions
end
then ur vb.net code can look like:
MyReader = MyCommand.ExecuteReader()
if MyReader.Read then
QuestionCount = cint(MyReader(0))
end if
MyReader.NextResult 'jumps to the 2nd select
if MyReader.Read Then
'do your other stuff here
End if
Btw, why call them "MyXXXX" who elses could they be?? :)
Karl
--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
"Bass Pro" <Ba*****@discussions.microsoft.com> wrote in message
news:D3**********************************@microsof t.com...
Hi Karl,
This is my code....
I didn't think there was a postback until after the button click event was
completed. Am I wrong in my thinking? New to asp.net so I'm at your
mercy...tks Bill
Imports System.Data.SqlClient
Imports System.Text.RegularExpressions
Imports Surveys.SurveysLibrary
Imports Surveys.CCExceptionLog
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.HtmlControls
Public Class Main
Inherits System.Web.UI.Page
Protected WithEvents lblFooter As System.Web.UI.WebControls.Label
.....