Form reloading when I write to array even though I'm not submitting the form...

wings9697

Member
Joined
Aug 27, 2007
Messages
23
Location
Washington, DC
Programming Experience
10+
Hi. I have a form that will be used to capture the pieces of evidence seized at a crime scene. It captures 6 fields,

Case Number , Case Agent , Criminal Complaint Number (CCN) - these are held in session variables, and the idea was to have them replaced in the text boxes on the form, so the user wouldn't have to retype them again and again...

Case Item Number - an incremented count of all items entered for that case

Item Description, Item Name - two data entry fields to capture info for each piece of property seized

When I set this form up with a FormView template, and a SQLDataSource connection to my Property table, I was able to see everything in the right place, but after I submit the record to the table, the data would go in, but my repetitive fields would not be replaced in the repective fields. But the kicker is, that I could see the data being placed in the right fields in the table, even though it wasn't on the form.

After a few well placed !$%#&'s, I then moved on to plan #2. I rebuilt the form with the intention to write the items to an array, then submit the entire array through ADO to my property table. This worked a little better, as my session variables appeared on each page, and the data wrote to the array with no problem. Then I tried to INSERT into the table... What I found when I set some breakpoints, was when I clicked my button to add the 6 fields to the array, the form would go back to the LOAD event, which reset all my counters. I was writing each new record to the same place. No matter where I moved the initialization logic for my counters, they would get reset. And I wasn't even submitting the form...

This created more !$%#&'s

I have been stuck here for almost a week. It makes no sense that there is no place to reset these textboxes. And I thought that if the form reloads, shouldn't the LOAD event get rerun too? The only other option I have is to make the user open the page, add the data, and close the page, repeating the process for each piece seized.... which would really drive me !$%#&

If anybody can tell me what I'm missing, I would be greatly appreciated the help.....

VB.NET:
Partial Class PropCollect
    Inherits System.Web.UI.Page
    Public newCOLL As Integer = 1
    Public ccnSET As String
    Public ck1 As String
    Public ck2 As String
    Public ck3 As String

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Me.Master.PageTitle = "Collection of Evidence Seized Information Page"

        Dim agentCH As TextBox
        Dim csesCH As TextBox
        Dim itemCNT As TextBox
        Dim ccnCH As TextBox
        Dim ck1 As String
        Dim ck2 As String
        Dim ck3 As String


        'Session("sesCaseNum") = usrCaseNum
        Response.Write(Session("sesCaseNum"))
        Response.Write(Session("sesAgtNum"))
        Response.Write(Session("sesRowNum"))
        Response.Write(Session("sesCCNNum"))

        ck1 = Session("sesCaseNum")
        ck2 = Session("sesAgtNum")
        ck3 = Session("sesCCNNum")

        'newCOLL = "1"

        agentCH = CType(FormView1.FindControl("pc_agentnumTextBox"), TextBox)
        csesCH = CType(FormView1.FindControl("pc_cses_numTextBox"), TextBox)
        itemCNT = CType(FormView1.FindControl("pc_item_numTextBox"), TextBox)
        ccnCH = CType(FormView1.FindControl("pc_ccnTextBox"), TextBox)
        'Move value to text positions 

        agentCH.Text = ck2
        csesCH.Text = ck1
        ccnCH.Text = ck3
        itemCNT.Text = Session("sesPRPNum")

    End Sub

    Protected Sub InsertButton_Click(ByVal sender As Object, ByVal e As System.EventArgs)

        Dim holdCNT As Integer

        holdCNT = Session("sesPRPNum")
        holdCNT = holdCNT + 1
        Session("sesPRPNum") = holdCNT

    End Sub
End Class
 
try this:

Partial Class PropCollect
Inherits System.Web.UI.Page
Public newCOLL As Integer = 1
Public ccnSET As String
Public ck1 As String
Public ck2 As String
Public ck3 As String

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

if not IsPostback then

Me.Master.PageTitle = "Collection of Evidence Seized Information Page"

Dim agentCH As TextBox
Dim csesCH As TextBox
Dim itemCNT As TextBox
Dim ccnCH As TextBox
Dim ck1 As String
Dim ck2 As String
Dim ck3 As String


'Session("sesCaseNum") = usrCaseNum
Response.Write(Session("sesCaseNum"))
Response.Write(Session("sesAgtNum"))
Response.Write(Session("sesRowNum"))
Response.Write(Session("sesCCNNum"))

ck1 = Session("sesCaseNum")
ck2 = Session("sesAgtNum")
ck3 = Session("sesCCNNum")

'newCOLL = "1"

agentCH = CType(FormView1.FindControl("pc_agentnumTextBox"), TextBox)
csesCH = CType(FormView1.FindControl("pc_cses_numTextBox"), TextBox)
itemCNT = CType(FormView1.FindControl("pc_item_numTextBox"), TextBox)
ccnCH = CType(FormView1.FindControl("pc_ccnTextBox"), TextBox)
'Move value to text positions

agentCH.Text = ck2
csesCH.Text = ck1
ccnCH.Text = ck3
itemCNT.Text = Session("sesPRPNum")
end if
End Sub

Protected Sub InsertButton_Click(ByVal sender As Object, ByVal e As System.EventArgs)

Dim holdCNT As Integer

holdCNT = Session("sesPRPNum")
holdCNT = holdCNT + 1
Session("sesPRPNum") = holdCNT

End Sub
End Class
 
Back
Top