Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8603159
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T02:15:31+00:00 2026-06-12T02:15:31+00:00

I have a GridView with each row containing a checkbox, and the header of

  • 0

I have a GridView with each row containing a checkbox, and the header of that column is a checkbox with checkAll functionality:

<Columns>
     <asp:TemplateField>
            <HeaderTemplate>
                   <input id="chkAll" onclick="javascript:SelectAllCheckboxes(this);"                                       runat="server" type="checkbox" />
            </HeaderTemplate>
            <ItemTemplate>
                   <asp:CheckBox ID="chkSelect" runat="server" ToolTip="Select this order" AutoPostBack="true" OnCheckedChanged="chkSelect_OnCheckedChanged"/>
            </ItemTemplate>
     </asp:TemplateField>
     ...More BoundFields
</Columns>

The javascript behind the SelectAllCheckboxes()

function SelectAllCheckboxes(spanChk) {

        // Added as ASPX uses SPAN for checkbox

        var oItem = spanChk.children;
        var theBox = (spanChk.type == "checkbox") ?
    spanChk : spanChk.children.item[0];
        xState = theBox.checked;
        elm = theBox.form.elements;

        for (i = 0; i < elm.length; i++)
            if (elm[i].type == "checkbox" &&
          elm[i].id != theBox.id) {
                //elm[i].click();

                if (elm[i].checked != xState)
                    elm[i].click();
                //elm[i].checked=xState;

            }
    }

My GridView basically contains sales (orders) from my website, so dollar amounts. The OnCheckedChanged event adds (if checked) or subtracts (if unchecked) the current row’s price from a totalAmount that is displayed on the page.
This all works great except that when I click the checkAll checkbox, all of the OnCheckedChanged events for all of the row check boxes fire and it takes a long time to process it all. Since all that I am doing in the OnCheckedChanged method is summing amounts, is there a way that I can NOT call the events for the individual checkboxes and just make one call to a separate method that will grab all the GridView rows and sum them all at once?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T02:15:32+00:00Added an answer on June 12, 2026 at 2:15 am

    If you consider doing it all on the server in one postback, you could try this:

    <Columns>
        <asp:TemplateField>
             <HeaderTemplate>
                  <asp:CheckBox ID="chkAll" runat="server" ToolTip="Select this order" AutoPostBack="true" OnCheckedChanged="chkAll_OnCheckedChanged"/>
             </HeaderTemplate>
             <ItemTemplate>
                  <asp:CheckBox ID="chkSelect" runat="server" ToolTip="Select this order" AutoPostBack="true" OnCheckedChanged="chkSelect_OnCheckedChanged"/>
             </ItemTemplate>
        </asp:TemplateField>
    </Columns>
    

    On the code behind:

        protected void chkSelect_OnCheckedChanged(object sender, EventArgs e)
        { 
            //Process checked item 
        }
    
        protected void chkAll_OnCheckedChanged(object sender, EventArgs e)
        {
            foreach (GridViewRow item in grdTest.Rows)
            {
                CheckBox ckb = (CheckBox)item.FindControl("chkSelect");
    
                //This will not call the individual event
                ckb.Checked = ((CheckBox)sender).Checked;
                //Process checked item 
            }
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have GridView with CheckBox in it's header and another one in each row:
I have a gridview on my ASP website that needs to process each row
Consider a gridview row containing two columns... Each column has two textboxes... Onkeypress in
I have asp.net's .aspx page. that have GridView let say GridViewParent and Each row
I have a gridview and sqldatasource. The default header text for each column is
I have a gridview control with delete asp:ImageButton for each row of the grid.
I have a delete button in each row of GridView (component ASP.NET). I want
I have an ASP.NET GridView that has four columns. The first three are typical
I have an ASP.net GridView that spits out three columns of data: ( OrderNumber,
I have a gridview that contains around 16 ItemTemplate columns. The values in each

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.