We help IT Professionals succeed at work.

uncheck checkbox

jaws1021
jaws1021 asked
on
1,184 Views
Last Modified: 2008-04-24
I get this error when I uncheck by checkbox in gridview.

Failed to load viewstate.  The control tree into which viewstate is being loaded must match the control tree that was used to save viewstate during the previous request.  For example, when adding controls dynamically, the controls added during a post-back must match the type and position of the controls added during the initial request.
Comment
Watch Question

can you please post the code?

Author

Commented:
I don't know which one to post? checkchanged handler maybe?
yes ..

Author

Commented:
This is my checkchanged event and works great when user check the check box, but when unchecked gives me viewstate problem, do you know why it is doing that? I need to figure it out asap, I on deadline here..

 Dim ck1 As CheckBox = CType(sender, CheckBox)
        If ck1.Checked = True Then
            Dim row As GridViewRow = CType(ck1.Parent.Parent, GridViewRow)
            Dim currentrow As Integer = row.RowIndex

            If Decimal.Parse("0" & row.Cells(2).Text) <> 21 Then

                Session("code_id") = Decimal.Parse("0" & row.Cells(2).Text)
                GridView1.SelectedIndex = currentrow
                GridView1.EditIndex = currentrow
                'BindGrid()
                           End If
        End If

        Fill_DropDown()
        GridView1.EditIndex = -1
    End Sub
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION

Author

Commented:
don't know :)  is that a problem?

Author

Commented:
You are the best!!!!!! I was suspecious about that one myself, didn't think that could cause problem.. It solved the problem. Thank you I will give your points asap, but you got a look at my new posting called this is strange , it is related to that and it is very strange thing happening when I set boundfield to visible= false, it doesn't create a sessionid for that datafield...

Thanks again!!
i did read that .. i was a bit confused with the requirement .. I will post my queries there ..
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.