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(ConnPor
tal, sqlstmt)
l = New Label
l.Text = " <br />"
PageBody.Controls.Add(l)
l = New Label
l.Text = "Logged on user: " & Request.ServerVariables("A
UTH_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.a
spx")
End Sub
Start Free Trial