ViewState problem: When Composite Control Inside Custom GridView

Discussion in 'ASP .Net Building Controls' started by Amit, Mar 7, 2008.

  1. Amit

    Amit Guest


    I have an issue while implementing Custom GridView control. My custom
    implementation is as below:


    I have implemented custom EnhancedGridView class inherited from “GridViewâ€
    class. For this custom GridView control I want to implement Search and Paging

    To implement Search and Paging functionality, I have implemented two
    separate CompositeControls as below:

    EnhancedGridViewSearch : Comprises server controls like TextBox, DropDown
    and Button
    EnhancedGridViewPager :

    I am creating above mentioned composite controls in overridden
    CreateChildControls(IEnumerable dataSource, bool dataBinding) method of
    EnhancedGridView class.

    The expected functionality of these controls works fine but I am facing
    following problem.


    After entering Search criteria in the fields of EnhancedGridViewSearch
    control and if I press “Run Search†button of this control, after post back,
    GridView is populated with new set of data as per the search criteria
    specified, but view state of the search controls (TextBox, DropDown) in
    EnhancedGridViewSearch is not maintained after post back.

    I think this is the problem since CreateChildControls () method of
    EnhancedGridView class is called twice first time after PostBack and second
    time after GridView is bind to a new set of data.

    I need some sort solution to maintain the ViewState of child controls of
    Composite Controls that are built inside GridView class.

    I am desperately seeking help for this issue.
    Please share your thoughts if you have something.

    Thanks in Advance
    Amit, Mar 7, 2008
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.