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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T18:04:10+00:00 2026-05-24T18:04:10+00:00

I am trying to implement a checkbox within gridview, The job of this checkbox

  • 0

I am trying to implement a checkbox within gridview,

The job of this checkbox is to verify a record,

When this verify button is pressed, all items with a checked checkbox are inputted into the database

This is my code:

    protected void Button1_Click(object sender, EventArgs e)
    {

        foreach (GridViewRow row in GridView1.Rows)
        {

             CheckBox cbox = ((CheckBox)row.FindControl("Verify"));

            if (cbox.Equals(true))
            {
                String DraftsText = ((TextBox)row.FindControl("numDrafts")).Text;
                String TCtext = ((TextBox)row.FindControl("numTC")).Text;

                if (row.RowType == DataControlRowType.DataRow)
                {
                    //Header trs = new Header();
                    // GridView1.Rows[0].FindControl("numTC");
                    if (TCtext != "" && DraftsText != "")
                    {

                        //  try
                        //  {
                        string date = row.Cells[4].Text;

                        DateTime dateTime = Convert.ToDateTime(date);
                        string dateFormatted = dateTime.ToString("d-MMM-yy");

                        string unit = row.Cells[5].Text;
                        string currency = row.Cells[6].Text;
                        string totalFC = row.Cells[7].Text;
                        string totalDC = row.Cells[8].Text;
                        int d = Convert.ToInt32(DraftsText);
                        int tc = Convert.ToInt32(TCtext);


                        hdr = new Header(d, tc, dateFormatted, unit, currency, totalFC, totalDC);
                        hdr.InsertFCTC(hdr);
                    }

                }

            }
        }
    }

I might be going at this the wrong way but in the if (cbox.Equals(true))
its giving me an exception: Object reference not set to an instance of an object.

Any idea what i can do to solve this?

Many Thanks

  • 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-24T18:04:11+00:00Added an answer on May 24, 2026 at 6:04 pm

    This if (cbox.Equals(true)) should be if (cbox.Checked)

    Since your cbox is a checkbox object it can’t be used to compare, so you have to use the cbox Checked Property, which will return true/false

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

Sidebar

Related Questions

I am trying to implement a gridview with checkbox column on asp.net (VB). when
I am trying to implement a Select All checkbox using primefaces component p:selectBooleanCheckbox and
I am trying to implement image as checkbox. I have a list with 2
Trying to implement a search similar to here .This searches properties based on city,locality,property
I have been trying to implement a CheckBox Node Tree, where the parent nodes
I have html like this: <div> <input type=checkbox id=checkbox, checked=checked/> <label for=checkbox>Copy values</label> </div>
i'm trying to implement a massive delete action to a list of items, where
I'm trying to implement what this answer suggests but without storing the display name
So I have this checkbox inside a gridview, and it is working properly for
I am trying to make the items in a ComboBox checkable. I tried this:

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.