CheckBox inside DataGrid problem

P

popobawa61

I have a DataGrid (ID=DataGrid1) and a PlaceHolder on an aspx page. In
the Init phase of the page, I dynamically add a template column
containing a CheckBox to DataGrid1. In the Load phase of the page, I
instantiate a DataGrid (ID=DataGrid2), add a template column
containing a checkbox to that grid and then add the DataGrid to the
placeholder.

The 1st time the page is hit, no CheckBoxes are selected in either
grid. Using my browser, I select a CheckBox in both of the grids, then
navigate to another page in one of the grids, forcing a postback to
the server.

My server code checks to see if any of the CheckBoxes are checked
within either of the grids. I perform this check in 2 phases of the
page lifecycle:
1: Page_Load (after adding DataGrid2 to the PlaceHolder on the page)
2: the event handler for the clicking on a page of the DataGrid.

For DataGrid2, the CheckBox reflects my client-side check only in case
#2, whereas DataGrid1 reflects my client-side check in both case 1 &
2.

It is my understanding that when a control is added to a page, it
plays catch-up within the page life cycle until it reaches the current
phase of the page. Since the page is in the Load phase when I added
DataGrid2 to it, DataGrid2 should have loaded its PostBack data and
thus reflect the client-side change I made by the time I scan the
CheckBoxes.

Does anyone know why my CheckBoxes do not reflect client-side checks I
made within DataGrid2 within Page_Load?

Thanks, Popo
 

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,768
Messages
2,569,574
Members
45,049
Latest member
Allen00Reed

Latest Threads

Top