views:

266

answers:

1

There is a check box in my webform. whenever i tick it ..and click on back button it will not retain its state ..when i comeback using the next button to the same page.

Note: view state is enabled in the control

There is no code in the page load event

Code below:

Protected Sub chkBx_SR_wu_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs) Handles chkBx_SR_wu.SelectedIndexChanged
    Dim i As Integer
    i = 0
    Try
        For i = 0 To chkBx_SR_wu.Items.Count - 1
            If chkBx_SR_wu.Items(i).Selected Then
                Select Case chkBx_SR_wu.Items(i).Value
                    Case "SR_MR"
                        chkbx_SR.Checked = True
                    Case "Sk_MR"
                        chkbx_SkRoom.Checked = True
                    Case "SC_SS"
                        chkbx_admin.Checked = True
                    Case "CS_MR"
                        chkbx_salesFloor.Checked = True
                    Case "TEAM_LEADER"
                        rb_tl.Enabled = True
                        chkbx_tlAdmin.Enabled = True
                        chkbx_tlJewellery.Enabled = True
                        chkbx_tlSalesFloor.Enabled = True
                        chkbx_tlSkRoom.Enabled = True
                        rb_tl.Items(0).Enabled = True
                        rb_tl.Items(1).Enabled = True
                        rb_tl.Items(2).Enabled = True
                        rb_tl.Items(3).Enabled = True
                        ReqiredFieldValidator1.Enabled = True



                End Select
            Else
                Select Case chkBx_SR_wu.Items(i).Value
                    Case "SR_MR"
                        chkbx_SR.Enabled = False
                        chkbx_SR.Checked = False
                    Case "Sk_MR"
                        chkbx_SkRoom.Enabled = False
                        chkbx_SkRoom.Checked = False
                    Case "SC_SS"
                        chkbx_admin.Enabled = False
                        chkbx_admin.Checked = False
                    Case "CS_MR"
                        chkbx_salesFloor.Enabled = False
                        chkbx_salesFloor.Checked = False
                    Case "TEAM_LEADER"
                        chkbx_tlAdmin.Enabled = False
                        chkbx_tlAdmin.Checked = False
                        chkbx_tlJewellery.Enabled = False
                        chkbx_tlJewellery.Checked = False
                        chkbx_tlSalesFloor.Enabled = False
                        chkbx_tlSalesFloor.Checked = False
                        chkbx_tlSkRoom.Enabled = False
                        chkbx_tlSkRoom.Checked = False
                        rb_tl.Items(0).Enabled = False
                        rb_tl.Items(1).Enabled = False
                        rb_tl.Items(2).Enabled = False
                        rb_tl.Items(3).Enabled = False
                        ReqiredFieldValidator1.Enabled = False
                End Select
            End If
        Next

    Catch ex As Exception

    End Try
End Sub"
+1  A: 

Checkboxes don't use ViewState to retain their state - they use the contents of the HTTP POST payload to determine whether or not to set the control as Checked.

If you need to persist this value beyond the normal postback cycle you will need to store it in session or somewhere similar that will survive beyond that timeframe.

Andrew Hare
Please tell me how to solve this issue ?
Could you explain a bit .. how to store it in session?
If you can, please post some of your code so that I can help you create a solution that will work for you.
Andrew Hare
Code has been give above..please look
Moreover, when i click on Next button to the new page and comeback state is retained.But when i click on the back button and come to the same page state is not retained