Checkboxes not saving state

Discussion in 'ASP .Net' started by arun.hallan, Aug 30, 2006.

  1. arun.hallan

    arun.hallan Guest

    Hi,

    I have a datagrid whose datasource is a datatable which is saved to
    viewstate on page_load.

    I also have a cached string which handles what is shown on the
    rowfilter of the dataview of this datatable.

    I also have a cached string that holds the way the dataview is sorted.

    Now, on my original datagrid i have a row of checkboxes added from the
    property builder. The HTML behind it is : <asp:CheckBox id="chkPrice"
    runat="server" AutoPostBack="true"
    OnCheckedChanged="chkPrice_CheckChanged" EnableViewState="True">

    As you can see when clicked, the method 'chkPrice_CheckChanged' is
    meant to be called. However i dont think it is being called. I know i
    it doesnt hit my breakpoint when i put one in.

    The chkPrice_CheckChanged is meant to save all the checkbox values to a
    hashtable so on the next page_load, the checkboxes can be filled again.

    Does anyone know why this method isnt called, and/or provide some light
    to the situation.

    Thanks,
    Arun
     
    arun.hallan, Aug 30, 2006
    #1
    1. Advertisements

  2. arun.hallan

    Teemu Keiski Guest

    Do you bind the dataGrid inside Not Page.IsPostBack or !Page.IsPostBack
    check so that accidental rebind on postback wouldn't "eat up" the events.
     
    Teemu Keiski, Aug 30, 2006
    #2
    1. Advertisements

  3. arun.hallan

    arun.hallan Guest

    I bind on page_load...

    The datasource of teh datagrid is a datatable.
    That is cached.

    The 'datasource' for the checkboxes is a hashtable. When a box is
    checked, i want to update the hashtable and save it to the cache.

    But the event to do this doesnt fire.
     
    arun.hallan, Aug 30, 2006
    #3
  4. arun.hallan

    Teemu Keiski Guest

    Yup, but in the Page_Load you do it inside If Not Page.IsPostBack check so
    that it wouldn't get databound on every request, that's the question? That
    will prevent events from firing.
     
    Teemu Keiski, Aug 30, 2006
    #4
  5. arun.hallan

    arun.hallan Guest

    On !postback the datagrid is filled with data from the database.

    Then teh datatable from this datagrid is saved into viewstate.

    On postback, teh datatable from viewstate is binded back to the
    datagrid.

    Is this not how i should do it?
     
    arun.hallan, Aug 31, 2006
    #5
  6. arun.hallan

    arun.hallan Guest

    Btw im not stupid - i can spell "the" !

     
    arun.hallan, Aug 31, 2006
    #6
  7. arun.hallan

    Ray Booysen Guest

    The question is whether you do the bind on every page_load.
     
    Ray Booysen, Aug 31, 2006
    #7
    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.