how to clear selected check box in gridview when click clear button

Gani_tpt 2,046 Reputation points

how to clear selected check box in gridview.

when i click clear button, all paging selected check box should clear by default.

How to do this..?

A set of technologies in the .NET Framework for building web applications and XML web services.
3,377 questions
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,508 questions
0 comments No comments
{count} votes

Accepted answer
  1. Lan Huang-MSFT 27,956 Reputation points Microsoft Vendor

    Hi @Gani_tpt,

    This is the same way you saved all your page data before.

    If you want to operate on all pages, you can use this method.

    You can use the command below to browse all pages and browse all rows in each page. You can also get the current page before doing this and return there after looping through everything.

    protected void btnClear_Click(object sender, EventArgs e)
         int a = gvCustomer.PageIndex;
         //Loop through All Pages
         for (int i = 0; i < gvCustomer.PageCount; i++)
             //Set Page Index
             //After Setting Page Index Loop through its Rows
             foreach (GridViewRow gvrow in gvCustomer.Rows)
                 if (gvrow.RowType == DataControlRowType.DataRow)
                     CheckBox chk = (CheckBox)gvrow.FindControl("CheckBox1");
                     chk.Checked = false;

    Best regards,
    Lan Huang

    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful