Wrox Home  
Search P2P Archive for: Go

  Return to Index  

aspx_beginners thread: asp:table state


Message #1 by "Greg Partin" <GPartin@c...> on Thu, 24 Oct 2002 15:30:51 -0700
hi folks,

For some weird reason my asp:table that I am creating on the fly in my
codebehind does not hold it's state on postback.  Here's some code:

Public Class cm_AddPS

    Inherits SuperPage

    Protected WithEvents PSRow As Me.AddPS
    Protected WithEvents btnSubmit As System.Web.UI.WebControls.Button
    Protected WithEvents tblInputs As System.Web.UI.WebControls.Table

    Const intRows As Integer = 30

 Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

        If ValidateSession() Then

            If Not Page.IsPostBack Then

                GenerateTable()

            End If

        End If

    End Sub

  Public Function GenerateTable() 'build the table with 30 rows and
place my control in each cell

        Dim x As Integer

        For x = 1 To intRows

            Dim Row As New System.Web.UI.WebControls.TableRow()
            Dim Cell As New System.Web.UI.WebControls.TableCell()
            Dim cntRowControl 
Page.LoadControl("../includes/MyControl.ascx")

            Me.tblInputs.Rows.Add(Row)
            Row.Cells.Add(Cell)
            Cell.Controls.Add(cntRowControl)

        Next

    End Function

 Private Function ValidateSession() As Boolean

        Dim blnSessionOK As Boolean

        blnSessionOK = Me.CheckSession()

        Return blnSessionOK

    End Function

    Private Sub btnSubmit_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles btnSubmit.Click

        ValidatePS()

    End Sub

Public Function ValidateCorrelations()

        Dim rdrReader As SqlDataReader()
        Dim dbObject As New CLO.Util.DB.DBUtil()
        Dim oQue As New System.Collections.Queue()
        Dim x

        For x = 1 To intRows

            Dim testrow As System.Web.UI.WebControls.TableRow
            Dim testcell As System.Web.UI.WebControls.TableCell
            Dim testrowobject As New CLO.AddPSCorrelationRow()
            Dim GradeDropDown As
System.Web.UI.WebControls.DropDownList
            Dim strGrade As String
          
            testrow = Me.tblInputs.Rows.Item(0) 'HERE IS WHERE IT
BOMBS.  THERE IS NO SUBSCRIPT 0 FOR TABLE ROW
            testcell = testrow.Cells(0)
            testrowobject = CType(testcell.Controls.Item(0),
AddPSCorrelationRow)
            GradeDropDown = CType(testrowobject.GetGradeObj,
DropDownList)
            strGrade = GradeDropDown.SelectedItem.Text

        Next

    End Function

End Class

So, i'm making a 30 row table and placing my user control into each
cell.  The table generates just fine, I can see it.  I push the Submit
button and it seems to "disapear".  Any thoughts?

thanks,
Greg

Greg Partin
Software Engineer

CompassLearning, Inc.
2400 N. Commerce Pkwy.
Suite #404
Weston, FL  33326

  Return to Index