Checkboxes not saving state

A

arun.hallan

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
 
T

Teemu Keiski

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.
 
A

arun.hallan

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.
 
T

Teemu Keiski

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.
 
A

arun.hallan

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?
 
A

arun.hallan

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

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?
 

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. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,073
Latest member
DarinCeden

Latest Threads

Top