troubleshooting Question

ASP.NET GridView unbound checkbox issue

Avatar of kevinvw1
kevinvw1 asked on
8 Comments2 Solutions1395 ViewsLast Modified:
I am populating a gridview with data from a stored procedure.  I also have a checkbox template column that is not bound.  I populate the grid just fine and then I check a checkbox and click a button to read the checkbox, but it always returns Checked = false.

I have set breakpoints so I know that the code is being executed.

Here is the code behind the button -

protected void btnUpdatePreferences_Click(object sender, EventArgs e)
        if (gvwPreferences.Rows.Count >= 1)
            foreach (GridViewRow row in gvwPreferences.Rows)
                if (row.RowType == DataControlRowType.DataRow)
                    CheckBox subscribe = (CheckBox)row.FindControl("Checkbox1");                

Any suggestions?
Thanks, Kevin.

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 2 Answers and 8 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 8 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros