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 111043
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T02:19:20+00:00 2026-05-11T02:19:20+00:00

I have a gridview that I have added a checkbox column using a templatefield

  • 0

I have a gridview that I have added a checkbox column using a templatefield (I want the user to be able to check/uncheck the box. I want to be able to populate the checkboxes, but when I try to cast the column as a Checkbox on the RowDataBound event, it errors. I also can’t do a FindControl due to the Masterpage (I think)

Any help would be appreciated!

The RowDataBound:

if (e.Row.RowType == DataControlRowType.DataRow) {

  var RowData = (ResponderResultViewClass)e.Row.DataItem;    // This control never gets found (due to the Masterpage I think)   CheckBox chkBox = (CheckBox)e.Row.FindControl('chkCertified');    // This throws an error saying 'Can't convert LiteralControl to Checkbox   CheckBox cb = (CheckBox)e.Row.Cells[4].Controls[0]; 

Here is the aspx code:

<asp:BoundField DataField='AnswerID' ControlStyle-Width='0' /> <asp:BoundField DataField='QuestionText' HeaderText='Question' /> <asp:BoundField DataField='AnswerText' HeaderText='Answer' ItemStyle-HorizontalAlign='Center' /> <asp:BoundField DataField='QualifyingGroupName' HeaderText='Qualifying Group' /> <asp:TemplateField HeaderText='Cert'>     <ItemStyle HorizontalAlign='Center' />         <ItemTemplate>             <asp:CheckBox ID='chkCertified' runat='server' />     </ItemTemplate> </asp:TemplateField> 
  • 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. 2026-05-11T02:19:21+00:00Added an answer on May 11, 2026 at 2:19 am

    Controls[0] isn’t the checkbox. ASP.NET will stick some HTML content in there as a LiteralControl, you’ll need to look to see which index is your checkbox or stick with FindControl.

    If you are just trying to bind the true/false to the checkbox, you can do so like this in your template column:

    <asp:TemplateField HeaderText='Cert'>     <ItemStyle HorizontalAlign='Center' />     <ItemTemplate>         <asp:CheckBox ID='chkCertified' runat='server' Checked='<%# Eval('IsChecked') %>' />     </ItemTemplate> </asp:TemplateField> 

    Where IsChecked is a property on your bound object.

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

Sidebar

Ask A Question

Stats

  • Questions 212k
  • Answers 212k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Update your column to another type, after change the column… May 12, 2026 at 10:19 pm
  • Editorial Team
    Editorial Team added an answer Indeed, following Maven philosophy and thus its conventions is a… May 12, 2026 at 10:19 pm
  • Editorial Team
    Editorial Team added an answer That's a fresh sample of MKMapView rotation with iPhone ccelerometer.… May 12, 2026 at 10:19 pm

Related Questions

I have a gridview that displays items details, I added two template fields one
I have a TemplateField that is dynamically added to a custom GridView. void ITemplate.InstantiateIn(System.Web.UI.Control
After posting this: Custom Header in GridView ...I have a related problem. I have
I have an extended GridView class, GridViewEx, which inherits from the basic ASP.NET gridview.

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.