how to programmatically set checkbox value in datagrid headertempl

G

Guest

Hi folks,

I have a datagrid which contains a template item checkbox column. I've
included a checkbox as a HeaderTemplate item which fires a server-side
function to check or uncheck all the values in the underlying datatable
column, and resets the binding to the datagrid.

The only problem is that, when the user pages back and forth in the
datagrid, their selection is overwritten with the default selection in page
load. So, if the user unchecks the Select All box and then pages forward in
the datagrid, the Select All box now shows the default value (checked).

Does anybody have any ideas on how to programmatically set the
headertemplate checkbox when the page posts back?

Thanks in advance,

Andre Ranieri

<HeaderTemplate>

<asp:CheckBox id="chkAll" Checked="True" OnCheckedChanged="CheckAll"
runat="server" AutoPostBack="true"

ToolTip="Select/Deselect All"></asp:CheckBox><font face="Webdings"
color="white" size="4">a</font><!-- <INPUT
onclick="javascript:SelectAllCheckboxes(this);" type="checkbox"> -->

</HeaderTemplate>
 
C

Craig Deelsnyder

Hi folks,

I have a datagrid which contains a template item checkbox column. I've
included a checkbox as a HeaderTemplate item which fires a server-side
function to check or uncheck all the values in the underlying datatable
column, and resets the binding to the datagrid.

The only problem is that, when the user pages back and forth in the
datagrid, their selection is overwritten with the default selection in
page
load. So, if the user unchecks the Select All box and then pages
forward in
the datagrid, the Select All box now shows the default value (checked).

Does anybody have any ideas on how to programmatically set the
headertemplate checkbox when the page posts back?

Thanks in advance,

Andre Ranieri

<HeaderTemplate>

<asp:CheckBox id="chkAll" Checked="True" OnCheckedChanged="CheckAll"
runat="server" AutoPostBack="true"

ToolTip="Select/Deselect All"></asp:CheckBox><font face="Webdings"
color="white" size="4">a</font><!-- <INPUT
onclick="javascript:SelectAllCheckboxes(this);" type="checkbox"> -->

</HeaderTemplate>

I believe the following has what you're looking for:
http://www.codeproject.com/aspnet/ChkBoxInGrid.asp
 
G

Guest

Craig,

I've been taking a look at the codeproject.com source samples, they're
pretty similar to the web app I'm building.

I might be misreading the article, but I'm not sure it addresses my core
question, which is how to change the value on the header checkbox itself.
I've already managed to manipulate the value on the item checkboxes when the
header checkbox is clicked, but I can't seem to affect the value of that
header checkbox itself, on postback when the datagrid page index changes.

Thanks in advance for any assistance,

Andre Ranieri
 

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

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,810
Latest member
Kassie0918

Latest Threads

Top