473,387 Members | 1,515 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

how to programmatically set checkbox value in datagrid headertempl

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>
Nov 19 '05 #1
2 5430
On Tue, 15 Mar 2005 14:03:06 -0600, Andre Ranieri""
<An**********@discussions.microsoft.com> wrote:
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

--
Craig Deelsnyder
Microsoft MVP - ASP/ASP.NET
Nov 19 '05 #2
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
Nov 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Sebi | last post by:
Hello all is it possible to add a checkbox in a DataGrid for Boolean Data? Thanks in advance
1
by: MS Newsgroups | last post by:
Hi, I have managed to create a Datagrid with a template column with checkboxes following Q306227. The dataset i have bound to the datagrid contains 1 column that allows NULL value and I would...
2
by: Marty | last post by:
I have a numeric Oracle field which stores -1 for true and 0 for false. I am trying to populate a checkbox in a datagrid. In my SQL statement, I used the Decode function so that when it populates...
1
by: Niclas Lindblom | last post by:
Hi, I have a datagrid that contains a checkbox template column. I have followed the sample in Q306227, but I have a problem evaluating the content of the datagrid columns to decide a value for...
7
by: Lars Netzel | last post by:
If I put a checkbox in a datagrid (ASP.NET) and set the Autopostback to true I can catch OnChange event on checkbox but how do I then catch what DataGridItemIndex is? Can I use some Event in the...
2
by: Asha | last post by:
greetings, i'm loading a datagrid and my gird has checkbox, i want these checkboxex to be check based on the value from the db? can someone please show me the code for it? thanks
10
by: Jennyfer J Barco | last post by:
Hello, I have a datagrid that brings some information from a query. I need to have a checkbox in each row so the user can select the rows he wants to reprint. Is it possible to have a checkbox...
9
by: Rekha | last post by:
The data is filled in datagrid. I want to know how to add a checkbox column in datagrid? In the runtime, checkbox is checked then instead of checkbox value the (caseID )column value is retained....
4
by: =?Utf-8?B?UGFycm90?= | last post by:
I cannot programmatically select a row in datagridview control. I use the following instruction to change the selection of a row dataGridView2.ClearSelection(); dataGridView2.Rows.Selected =...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.