GridView, Checkbox column.

I'm coding an ASP.NET project in VB.NET.  I'm using the GridView control.  It's bound to a data table. The first column of the data table is defined as col0.DataType = System.Type.GetType("System.Boolean").   This manifests itself as a checkbox column in the grid.  From code, I can set the value of the first column in the data table and it is reflected correctly in the grid.  I can loop through the rows in the grid and reference the first column and retrieve the boolean value.  However, the  checkbox column in the grid is always disabled.

How do I enable the  checkbox/boolean column?

Thanks
LVL 1
HLRosenbergerAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

cdaly33Commented:
So you're wanting the grid rows to be editable?  Here's a good article on how to setup an editable grid.
http://msdn.microsoft.com/en-us/library/ms972948.aspx
0
HLRosenbergerAuthor Commented:
I'll take a look at it.  I don't want all columns to be editable?   I just want to be able to check and uncheck the checkbox column.
0
cdaly33Commented:
You'll have to set the entire grid as editable then mark all other columns readonly.  I'm assuming that you do want to save the value of the checkboxes after they change right?
0
Introduction to Web Design

Develop a strong foundation and understanding of web design by learning HTML, CSS, and additional tools to help you develop your own website.

HLRosenbergerAuthor Commented:
That works.   Is it easy to set the entire grid as editable?
0
cdaly33Commented:
That previous link will create an Edit link to allow a user edit the checkbox.  If you want the entire grid editable when the page loads you will need to use a control other than the asp.net built-in gridview.  Here is an article on bulk edits.
http://blogs.msdn.com/mattdotson/articles/490868.aspx
0
HLRosenbergerAuthor Commented:
All I want is a checkbox in a column that allows me to select multiple rows.
0
cdaly33Commented:
In your original question you indicated that the checkbox is bound to data.  If you want it to be bound to the data then you'd naturally want to save the changing of the checkboxes.

If it's not bound to the data then forget the edit mode stuff.  Just add an unbound column and in it's item template add a checkbox.


0
HLRosenbergerAuthor Commented:
This problem is solved as follows:

Dim chk As New CheckBox

            cell = e.Row.Cells(0)
            cell.Width = New Unit("20")
            cell.Enabled = True
            chk.ID = "IsSelected"
            cell.Controls.Add(chk)
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.