Control inside Web Part is empty after normal PostBack

Last post 12-18-2007 6:19 AM by Deleo. 5 replies.

Sort Posts:

  • Control inside Web Part is empty after normal PostBack

    12-13-2007, 9:04 AM
    • Loading...
    • sparrez
    • Joined on 12-04-2006, 1:51 PM
    • Posts 27

    I have a Web Part deployed on a SharePoint site.

    The Web Part have some search functionality and when the user clicks a button a CheckBoxList is genereted based on the results of the search. Now the user can select/deselect items from the list and then click another button the should have some other functionality.

    My problem is that when the second button is clicked and the page returns the CheckBoxList is now empty. How should a Web Part be designed if I want this two-step thingie to work. I can't seem to figure it out.

    Filed under: , ,
  • Re: Control inside Web Part is empty after normal PostBack

    12-13-2007, 9:59 PM
    • Loading...
    • vinz
    • Joined on 10-05-2007, 11:47 AM
    • Cebu Philippines
    • Posts 7,362

    Try to wrap your codes in !IsPostBack method

    if(!Page.IsPostBack) 

    {

     //Place your codes here for generating CheckBox list

    Cheers,
    Vincent Maverick Durano

    "Life is like music; it must be composed by ear, feeling, and instinct, not by rule..."

  • Re: Control inside Web Part is empty after normal PostBack

    12-14-2007, 7:08 AM
    • Loading...
    • sparrez
    • Joined on 12-04-2006, 1:51 PM
    • Posts 27

    Thanks for your answer, but it didn't help much, it's like it completely drops any knowledge about the checkbox list when the second postback happens Confused

  • Re: Control inside Web Part is empty after normal PostBack

    12-18-2007, 6:16 AM
    • Loading...
    • Deleo
    • Joined on 11-04-2007, 3:33 PM
    • Posts 162

    Have you enabled viewstate and session? Just to check if its that

     

  • Re: Control inside Web Part is empty after normal PostBack

    12-18-2007, 6:19 AM
    • Loading...
    • Deleo
    • Joined on 11-04-2007, 3:33 PM
    • Posts 162

    Are you adding the checkboxes in the OnInit? If you havent added the checkboxes in the init, they will not be apart of the viewstate, hence their state is not conserved.

     

  • Re: Control inside Web Part is empty after normal PostBack

    12-18-2007, 6:19 AM
    Answer
    • Loading...
    • Deleo
    • Joined on 11-04-2007, 3:33 PM
    • Posts 162

    Might consider using session to store some states :)

     

Page 1 of 1 (6 items)
Microsoft Communities
Page view counter