Advertisement

07.01.2008 at 11:55AM PDT, ID: 23531271
[x]
Attachment Details

how do i save dynamic checkbox status before postback

Asked by blingtec903 in Microsoft Visual Basic.Net, Programming for ASP.NET, VB Objects

Tags: vb.net

i need to save checjboxes that were created on page load,the checkboxes have an id that is from the database.and i need to create an array to save what was checked and not the unckeched here is my page load
    Public Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Dim CNAME As String
        Dim PNAME As String
        Dim DATE1 As String
        Dim TIME As String
        Dim LOC As String
        Dim REMSEAT As String
        Dim CDESC As String

        Call localDBConnectionOpen()

        sqlstmt = "SELECT * FROM CHRTR"
        rs = DBRecordSetNewFast(ConnPortal, sqlstmt)
        l = New Label
        l.Text = "&nbsp;<br />"
        PageBody.Controls.Add(l)
        l = New Label
        l.Text = "Logged on user: " & Request.ServerVariables("AUTH_USER")
        PageBody.Controls.Add(l)

        ' loop the table and print a header for each database entry
        t = New Table
        t.Width = Unit.Percentage(100)


        While Not rs.EOF
            ' creates the table for the diplay
            r = New TableRow
            r.VerticalAlign = VerticalAlign.Bottom
            r.CssClass = "StandardRowHeader"
            c = New TableHeaderCell
            c.Text = "Course Name"
            r.Controls.Add(c)
            c = New TableCell
            c.Text = "Presenters Name"
            r.Controls.Add(c)
            c = New TableHeaderCell
            c.Text = "Date"
            r.Controls.Add(c)
            c = New TableHeaderCell
            c.Text = "Time"
            r.Controls.Add(c)
            c = New TableHeaderCell
            c.Text = "Location"
            r.Controls.Add(c)
            c = New TableHeaderCell
            c.Text = "Remaning Seats"
            r.Controls.Add(c)
            c = New TableHeaderCell
            c.Text = "Course Description"
            r.Controls.Add(c)
            c = New TableHeaderCell
            c.Text = "Register"
            r.Controls.Add(c)
            t.Controls.Add(r)
            CNAME = DBGetField(rs, "CNAME")
            PNAME = DBGetField(rs, "PNAME")
            DATE1 = DBGetField(rs, "DATE")
            TIME = DBGetField(rs, "TIME")
            LOC = DBGetField(rs, "LOC")
            REMSEAT = DBGetField(rs, "REMSEAT")
            CDESC = DBGetField(rs, "CDESC")
            ID = DBGetField(rs, "ID")
            r = New TableRow
            ct += 1
            If ct Mod 2 = 0 Then
                r.CssClass = "StandardRowEven"
            Else
                r.CssClass = "StandardRowOdd"
            End If
            ' call to the varabkes that hold the data from the database

            Call CellAdd(r, CNAME.ToString)
            Call CellAdd(r, PNAME.ToString)
            Call CellAdd(r, DATE1.ToString)
            Call CellAdd(r, TIME.ToString)
            Call CellAdd(r, LOC.ToString)
            Call CellAdd(r, REMSEAT.ToString)
            Call CellAdd(r, CDESC.ToString)
            Call CellAdd(r, "<center><a href=""register.aspx" & ID & """></a></center>")
            check = New CheckBox
            check.ID = ID ' makes the id the name of the checkbox
            check.Text = " Regizter"
            c.Controls.Add(check)
            check.AutoPostBack = True
            t.Controls.Add(r)
            rs.MoveNext()
        End While
        PageBody.Controls.Add(t)
        rs = DBRecordSetDestroy(rs)
        Call localDBConnectionClose()
    End Sub


AND MY BUTTON THTA TRIGGERS THE POSTBACK
    Protected Sub Button1_Click1(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
        If IsPostBack = True Then
            Dim p As Integer
            For p = 0 To ct
                check = c.FindControl(ID)
                If check.Checked = True Then
                    Response.Write(check.ID) 'just for testing
                End If
            Next
        End If
        ' Response.Redirect("login.aspx")
    End SubStart Free Trial
[+][-]07.01.2008 at 12:35PM PDT, ID: 21910835

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.17.2008 at 06:10AM PDT, ID: 22024976

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Microsoft Visual Basic.Net, Programming for ASP.NET, VB Objects
Tags: vb.net
Sign Up Now!
Solution Provided By: blingtec903
Participating Experts: 1
Solution Grade: A
 
 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628