PDA

Click to See Complete Forum and Search --> : Newb Question


SeanGrebey
Dec 9th, 2004, 10:17 AM
Ok, long time programmer, new to web development....

Trying to figure out why my class level variables get reset....here is the code. In my Page_Load, I am setting a TaskID and a UserID. But when I go to Submit, the values have been reset to zero...

Public Class Task
Inherits System.Web.UI.Page

Private intTaskID As System.Int32
Private intUserID As System.Int32

...

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here

If Not IsPostBack Then

intTaskID = CInt(Request.QueryString("TaskID"))

LoadUsernameList()

If intTaskID <> -1 Then
LoadTask()
Else
LoadUserID()
End If

...

End If

At the end of the Page_Load, intTaskID = 3 and intUserID = 1. But when I click the Submit button (no other actions taken), they are both set to 0 again. Why are they getting reset? Thanks for any help....

Private Sub btnSubmit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSubmit.Click
Dim strSQL As String
Dim cmd As New SqlClient.SqlCommand
cmd.Connection = SqlConn

cmd.Parameters.Add("@UserID", m_intUserID)
cmd.Parameters.Add("@AssignDate", txtDateAssigned.Text)
cmd.Parameters.Add("@DueDate", txtDateDue.Text)
cmd.Parameters.Add("@CompleteDate", txtDateCompleted.Text)
cmd.Parameters.Add("@Title", txtTitle.Text)
cmd.Parameters.Add("@Description", txtDescription.Text)
cmd.Parameters.Add("@Priority", ddlPriority.SelectedIndex)
cmd.Parameters.Add("@Accepted", ddlAccepted.SelectedIndex)
cmd.Parameters.Add("@Closed", ddlClosed.SelectedIndex)
cmd.Parameters.Add("@ManagerNotes", txtManagerNotes.Text)

If intTaskID > -1 Then

...

mendhak
Dec 9th, 2004, 10:43 PM
I've only glanced quickly, but can you step through it and follow the value? What are you getting?