[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

5.0

Checkboxes not reintializing

Asked by dbedoo in Active Server Pages (ASP), Programming for ASP.NET

Tags: ASP.NET, 2003, VB

Hi Experts,
   I have an ASP.NET app that I am building for user security in my current intranet.  The problem Im having is I have a panel that dynamical grabs a list which I represent with a list of checkboxes.  It populates the value of the checkboxes checked or unchecked correctly.  The problem is when change some check value hit submit, I noticed that the db was not updated correctly and when the page came back I still had all of the "modified" changes on the page.  This is odd as I requery and rebuild the textboxes upon and update.  So in a nutshell I make changes hit post it is supposed to update the db and after updating it call the methods that rebuild the control and check or uncheck accordingly, but its not working.  I have stepped through the code and I watch it setting up the controls correctly but renders the old page??  

Here is a snippet to give you an idea :

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        If IsPostBack Then
            doProcedures()
        Else
            pnSecurity.Style.Add("display", "none")
            indyDiv.Style.Add("display", "none")
        End If
    End Sub

    Private Sub doProcedures()
        Dim rv As New CRIdal.retVal
        Dim btn As String
        Dim employeeID As String = rv.returnedVal(Request, "lbEmployees")
        Dim empInfo As String()
        Dim security As String()
        Dim grpPolicy As String = rv.returnedVal(Request, "grpPolicy")
        Dim scView As Boolean

        btn = rv.whatButton(Request)
        Call intialize()

        Select Case btn
            Case "btnSaveSecurity"
                'Dim userid As Integer = rv.returnedVal(Request, CInt(txtUserID.Text))
                Call getItemizedSecuritySelected()
                Call loadUserInfo()
                Me.Controls.Add(New LiteralControl("<script>indyDivDisplay('indyDiv', 'pnSecurity', 1);openSCSecDiv('cbSCView', 'pnSecurityBreakout')</script>"))
          end select
         End sub

    Private Function getItemizedSecurity(ByVal userID As String) As String()
        Dim sqlState, errText As String
        Dim reader As SqlDataReader
        Dim sqlConn As New SqlConnection
        Dim qdb As New CRIdal.queryDBase
        Dim itemizedSecurity As String()

        sqlState = "SELECT readOnly, scView, fiscalView, irTracking, scAll, officeAll, programsAll FROM mydb WHERE userID = " & userID

        Try
            If qdb.queryDbase(sqlState, sqlConn, reader, False, errText, ) Then
                If reader.Read Then
                    ReDim Preserve itemizedSecurity(6)
                    itemizedSecurity(0) = reader.GetBoolean(0) 'ReadOnly
                    itemizedSecurity(1) = reader.GetBoolean(1) 'scView
                    itemizedSecurity(2) = reader.GetBoolean(2) 'fiscalView
                    itemizedSecurity(3) = reader.GetBoolean(3) 'IRTracking
                    itemizedSecurity(4) = reader.GetBoolean(4) 'scALL
                    itemizedSecurity(5) = reader.GetBoolean(5) 'officeALL
                    itemizedSecurity(6) = reader.GetBoolean(6) 'programsAll
                    qdb.closeConnections(reader, sqlConn)
                    Return itemizedSecurity
                Else
                    qdb.closeConnections(reader, sqlConn)
                End If
                Return Nothing
            Else
                qdb.closeConnections(reader, sqlConn)
            End If
        Catch ex As Exception
            qdb.closeConnections(reader, sqlConn)
        End Try
    End Function

    Private Sub loadUserInfo()
        Dim btn As String
        Dim employeeID As String
        Dim empInfo As String()
        Dim security As String()
        Dim grpPolicy As String
        Dim scView As Boolean
        Dim rv As New CRIdal.retVal

        employeeID = rv.returnedVal(Request, "lbEmployees")
        Call getEmployeeInfo(employeeID, empInfo)
        If Not empInfo Is Nothing Then
            Call loadControls(empInfo, scView)
            security = getItemizedSecurity(empInfo(0)) 'Call procedure if individual security.
            Call loadSCItemizedPanels(security)
        Else
            lblErrMessage.Text = "Employee found but is not registered.  Please register employee and try again."
        End If
    End Sub
    Private Sub loadSCSelection(Optional ByVal checkExisting As Boolean = False)
        Dim sqlState, errText As String
        Dim reader As SqlDataReader
        Dim sqlConn As New SqlConnection
        Dim qdb As New CRIdal.queryDBase
        Dim i, j As Integer
        Dim holdArray As String
        Dim allCheck, allEditCheck As Boolean
        Dim chkBox As CheckBox
        Dim chkBox2 As CheckBox
        Dim sc As String(,)

        sqlState = "SELECT coordinator_last + ', ' + coordinator_first, coordinator_id FROM mydb WHERE status = 'active' order by coordinator_last"
        Try
            If qdb.queryDbase(sqlState, sqlConn, reader, False, errText, ) Then
                If reader.HasRows Then
                    With pnSCSelection.Controls
                        .Add(New LiteralControl("<br><br>Service Coordinator Caseload<br><br>"))
                        .Add(New LiteralControl("<table border=1 width=90%><tr><td align=center>Edit</td>" & _
                                                                    "<td align=center>Read</td>" & _
                                                                    "<td align=center>SC Name</td></tr>"))
                    End With
                    'check here for all if checkExisting if yes set edit all flag
                    '////////////////////////////////////////////////////////////
                    'chkBox2.Attributes.Add("onclick", "selectAll('" & chkBox2.ID & "', " & holdArray & ")")
                    While reader.Read
                        ReDim Preserve sc(1, j)
                        sc(0, j) = reader.GetString(0)  'SCName
                        sc(1, j) = reader.GetInt32(1)    'SCID
                        If holdArray = "" Then holdArray = sc(1, j) _
                        Else holdArray += ", " & sc(1, j)
                        j += 1
                    End While
                    If allExists("editAll") Then
                        allEditCheck = True
                        chkBox2 = createCheckBoxControl("cbEdit", "", -1, -1, True, holdArray)
                    Else
                        chkBox2 = createCheckBoxControl("cbEdit", "", -1, -1, False, holdArray)
                    End If
                    '-->  
                    'check here for all if checkExisting if yes set all sc flag
                    '///////////////////////////////////////////////////////////
                    If allExists("scAll") Then
                        allCheck = True
                        chkBox = createCheckBoxControl("cbSC", "", -1, -1, True, holdArray)
                    Else
                        chkBox = createCheckBoxControl("cbSC", "", -1, -1, False, holdArray)
                    End If
                    With pnSCSelection.Controls
                        .Add(New LiteralControl("<tr><td align=center>"))
                        .Add(chkBox2)
                        .Add(New LiteralControl("</td><td align=center>"))
                        .Add(chkBox)
                        .Add(New LiteralControl("</td><td>&nbsp;&nbsp;"))
                        .Add(New LiteralControl("All SC"))
                        .Add(New LiteralControl("</td></tr>"))
                        '.Add(New LiteralControl("<br>"))
                        '-->
                    End With
                    Dim test As String = sc.GetUpperBound(1)
                    While i <= sc.GetUpperBound(1)
                        'check here for sc security here if checkExisting
                        '////////////////////////////////////////////////
                        Dim scName As String = sc(0, i)
                        Dim scid As Integer = sc(1, i)

                        ''check for edit
                        If Not allEditCheck Then
                            'Enters here if AllEditCheck=false
                            If secRowCheck("scSecFilter", scid, "scid", "editRights") Then
                                'Check if row exists for edit in scSecFilter
                                chkBox2 = createCheckBoxControl("cbEdit", "", scid, i, True)
                                chkBox = createCheckBoxControl("cbSC", "", scid, i, True)
                            Else
                                'Edit Flag doesnt exist or row doesnt exist check read flag
                                chkBox2 = createCheckBoxControl("cbEdit", "", scid, i)
                                If Not allCheck Then
                                    If secRowCheck("scSecFilter", scid, "scid", "readRights") Then
                                        chkBox = createCheckBoxControl("cbSC", "", scid, i, True)
                                    Else
                                        chkBox = createCheckBoxControl("cbSC", "", scid, i)
                                    End If
                                Else
                                    chkBox = createCheckBoxControl("cbSC", "", scid, i)
                                End If
                            End If
                        Else
                            chkBox2 = createCheckBoxControl("cbEdit", "", scid, i, True)
                            'If Not allCheck Then
                            '    If secRowCheck("scSecFilter", scid, "scid", "readRights") Then
                            '        chkBox = createCheckBoxControl("cbSC", "", scid, i, True)
                            '    Else
                            '        chkBox = createCheckBoxControl("cbSC", "", scid, i)
                            '    End If
                            'Else
                                chkBox = createCheckBoxControl("cbSC", "", scid, i, True)
                                'End If
                        End If
                        With pnSCSelection.Controls
                            .Add(New LiteralControl("<tr><td align=center>"))
                            .Add(chkBox2)
                            .Add(New LiteralControl("</td><td align=center>"))
                            .Add(chkBox)
                            .Add(New LiteralControl("</td><td>&nbsp;&nbsp;"))
                            .Add(New LiteralControl(scName))
                            .Add(New LiteralControl("</td></tr>"))
                            i += 1
                        End With
                    End While
                    qdb.closeConnections(reader, sqlConn)
                    pnSCSelection.Controls.Add(New LiteralControl("</table>"))
                Else
                    Response.Write("No Rows Returned:Line#827")
                    qdb.closeConnections(reader, sqlConn)
                End If
            Else
                Response.Write("No Similar Records: Null condition ln:831")
                qdb.closeConnections(reader, sqlConn)
            End If
        Catch ex As Exception
            qdb.closeConnections(reader, sqlConn)
        End Try
    End Sub


I left some functions out but point being ...  I step through the same code that is executed on load  after i udate the db but the same control values are returned   NOT the correct values from the DB?   Is there a way to implicitly dispose of the panels that contain the checkboxes ....

A work around would be to response redirect it but Id rather not because that will require passing around more "ids" and I want to avoid if possible.  Thanks in advance
[+][-]08/16/07 01:32 PM, ID: 19712119Expert Comment

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 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]08/16/07 01:34 PM, ID: 19712134Expert Comment

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 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]08/16/07 01:42 PM, ID: 19712207Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

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

 
[+][-]08/16/07 01:43 PM, ID: 19712212Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

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

 
[+][-]08/16/07 01:46 PM, ID: 19712245Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

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

 
[+][-]08/16/07 01:49 PM, ID: 19712270Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

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

 
[+][-]08/16/07 01:50 PM, ID: 19712288Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

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

 
[+][-]08/16/07 01:52 PM, ID: 19712305Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

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

 
[+][-]08/16/07 01:54 PM, ID: 19712338Expert Comment

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 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]08/16/07 01:56 PM, ID: 19712358Expert Comment

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 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]08/16/07 02:14 PM, ID: 19712533Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

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

 
[+][-]08/16/07 02:19 PM, ID: 19712572Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

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

 
[+][-]08/16/07 02:24 PM, ID: 19712617Expert Comment

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 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]08/16/07 02:25 PM, ID: 19712626Expert Comment

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 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]08/16/07 02:38 PM, ID: 19712740Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

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

 
[+][-]08/16/07 02:42 PM, ID: 19712769Accepted Solution

View this solution now by starting your 30-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: Active Server Pages (ASP), Programming for ASP.NET
Tags: ASP.NET, 2003, VB
Sign Up Now!
Solution Provided By: Justin_W
Participating Experts: 2
Solution Grade: A
 
[+][-]08/16/07 02:57 PM, ID: 19712889Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

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

 
[+][-]08/16/07 03:04 PM, ID: 19712958Expert Comment

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 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]08/16/07 03:06 PM, ID: 19712977Expert Comment

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 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]08/16/07 03:19 PM, ID: 19713110Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

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

 
[+][-]08/16/07 03:26 PM, ID: 19713169Expert Comment

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 30-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091021-EE-VQP-81 / EE_QW_2_20070628