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

  • Home
  • SEARCH
  • 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 7052243
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T03:21:37+00:00 2026-05-28T03:21:37+00:00

I have a gridview that has a template field containing a checkbox as one

  • 0

I have a gridview that has a template field containing a checkbox as one of the fields

<asp:TemplateField HeaderText="Confirm Driver Details" FooterText="Confirm Driver Details">
    <ItemTemplate>
        <asp:CheckBox ID="chkConfirmDetails" runat="server" MaxLength="100" Width="50px" Enabled="false" Checked="true"></asp:CheckBox>
    </ItemTemplate>
</asp:TemplateField>

Initially this is checked and not enabled.

The user uploads a file which is loaded into an object and then bound to the gridview. On the RowDataBound event some validation is performed on the data. In certain cases if some of the validation fails I want to enable the checkbox and untick it.

CheckBox chkConfirmDetails = (CheckBox)e.Row.Cells[e.Row.Cells.Count - 2].FindControl("chkConfirmDetails");

//If this is enabled then we just need to check whether it is ticked or not
if (!chkConfirmDetails.Enabled)
{
    if (!ValidateDriver(_uploadData.DriverData[e.Row.DataItemIndex], out driverValidationMessage))
    {
        Label label = new Label();
        label.Text = "Details of this Driver cannot be found<br />Please double-check to see if the Driver Number, Date of Birth and PPSN are entered correctly<br />If you are sure you have the correct details entered tick this box to confirm";
        e.Row.Cells[e.Row.Cells.Count - 2].Controls.Add(label);
        e.Row.Cells[e.Row.Cells.Count - 2].BackColor = System.Drawing.Color.Yellow;
        ((TableRow)e.Row.Cells[e.Row.Cells.Count - 2].Parent).BackColor = System.Drawing.Color.Red;
        chkConfirmDetails.Enabled = true;
        chkConfirmDetails.Checked = false;
        _numberOfInvalidCells++;
    }
}

This all works fine, the checkbox becomes enabled and is unticked.

The user can then choose to tick the box to confirm that the details are correct and re-validate the row. On each row of the datagrid there is a button that the user can click to perform this function. So when the user clicks the validate row button the above code is called again. This time the checkbox is enabled and may or may not be ticked depending on what the user has done.

However when I get a reference to the checkbox by using the FindControl method it is still showing up as Not Enabled and Checked (even if it is enabled and Not Checked on the form)

Can someone explain why this is occurring and a way to get the actual state of the checkbox?

EDIT

Looking at the Request.Form.AllKeys data, it has keys for most of the other template items in the gridview (textboxes and dropDownLists) but not the checkbox or the validate button

  • 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-05-28T03:21:37+00:00Added an answer on May 28, 2026 at 3:21 am

    RowDataBound is only called if you DataBind the GridView to it’s DataSource.
    That means you’ve called it before. But as a result all changes made by the user are overridden.

    So the question is, why did you need to call GridView.DataBind() fro revalidation? Can’t you do this in a method that iterates all GridViewRows?

    By the way, Is there a specific reason why you used

    (CheckBox)e.Row.Cells[e.Row.Cells.Count - 2].FindControl("chkConfirmDetails")

    instead of simply

    (CheckBox)e.Row.FindControl("chkConfirmDetails")?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a gridview with a template field that has a HyperLink: <asp:TemplateField ItemStyle-Width=12%
In a gridview I have the following Template Field containing a textbox <asp:TemplateField ShowHeader=true
I currently have a gridview that has an asp:ButtonField as one of the columns.
I have a GridView which has following template field that holds the filename, when
I have a Gridview in which one of the template fields has a radiobuttonlist
I have a GridView on an ASP.NET page with a TemplateField column that has
I have a GridView control in an Asp.net application, that has a <asp:buttonField> of
I have an ASP.NET GridView which has columns that look like this: | Foo
I have an ASP.NET GridView that has four columns. The first three are typical
I have a VS2010 ASP.Net webform that contains a GridView. This GridView has ShowHeaderWhenEmpty=True

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.