Composite Control Question: Re-creating DataGrid child control upon Postback?

Discussion in 'ASP .Net Building Controls' started by debartsa, Apr 22, 2004.

  1. debartsa

    debartsa Guest

    Hi Everybody,

    I have a composite control (in C#) which creates a DataGrid child control
    that binds to a DataSource (DataSet resultant from a sql query) passed in by
    the consuming .aspx. The .aspx page does the typical... if (!Postback)
    { //define datasource and bind } My question is how does my composite
    control recreate the DataGrid from ViewState upon postback? i.e. When
    postback occurs I can't use the DataSource passed in from the .aspx page?

    I've read msdn articles that explain creating a dummy datasource to be used
    upon postback? But how do I populated the dummy datasource with the same
    values I originally got from my initial sql query?

    Thanks for any help!
    Sam
    debartsa, Apr 22, 2004
    #1
    1. Advertising

  2. "debartsa" <> wrote in message
    news:%...
    > Hi Everybody,
    >
    > I have a composite control (in C#) which creates a DataGrid child control
    > that binds to a DataSource (DataSet resultant from a sql query) passed in

    by
    > the consuming .aspx. The .aspx page does the typical... if

    (!Postback)
    > { //define datasource and bind } My question is how does my composite
    > control recreate the DataGrid from ViewState upon postback? i.e. When
    > postback occurs I can't use the DataSource passed in from the .aspx page?
    >
    > I've read msdn articles that explain creating a dummy datasource to be

    used
    > upon postback? But how do I populated the dummy datasource with the same
    > values I originally got from my initial sql query?


    On postback, just create the datagrid and add it to your Controls
    collection. It will restore from ViewState, same as it saved there.
    --
    John Saunders
    John.Saunders at SurfControl.com
    John Saunders, Apr 23, 2004
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jacky Chau
    Replies:
    2
    Views:
    2,012
    Ninjamyst
    Jun 8, 2005
  2. Jeff Rodriguez
    Replies:
    23
    Views:
    1,070
    David Schwartz
    Dec 9, 2003
  3. debartsa

    Composite Control not receiving DataGrid (child control) events?

    debartsa, Apr 19, 2004, in forum: ASP .Net Building Controls
    Replies:
    0
    Views:
    177
    debartsa
    Apr 19, 2004
  4. Chad
    Replies:
    0
    Views:
    205
  5. Replies:
    0
    Views:
    163
Loading...

Share This Page