GridView - invisible column and checkbox column

I'm using the GridView.   I want to make a column invisible.  It is bound to a DataTable.  I have encountered a number of issue in trying to accomplish this.  

The ColumnName of the column in the DataTable is used as the column header text.  If I set this  to nothing, I get default text in the Column Header of "Column1".   Because I can't set the ColumnName of the column to nothing, this prevent the column form being invisible even if I set the invisible property to false and width to 0.   Bottom line, I can't get this column to totally disappear.  Is there a trick?  The invisible column is an a key value for the data in the row.  Is there a way to associate a key value with the row, without using a distinct column?  

Also, one of my columns is a check box.  I get the check box in theGridView by using a column in the DataTable with DataType = System.Type.GetType("System.Boolean").  However, the check box column is disabled.  How can I make it enabled?

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.

Kumaraswamy RCommented:
Hi

Bellow url give some information

http://www.asp.net/Learn/data-access/tutorial-52-vb.aspx
0
drypzCommented:
Hi! You may hide your column during databound event of your row. Something like this
    protected void GridView1_RowDataBound(object sender, System.Web.UI.WebControls.GridViewRowEventArgs e)
    {
        //assuming you want to hide column 0
        //you can hide to the user but still you can access its value
        e.Row.Cells[0].Attributes.Add("style", "display:none");
    }

Your question regarding disabled checkbox, this is enabled during Edit Mode of your gridview. 

Hope this helps.

Open in new window

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
samsymonCommented:
on rowdatabount of the grid
just add

e.Row.Cells(<COLUMN YOU WANT TO HIDE>).Style.Add("display", "none");

0
Become a CompTIA Certified Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

HLRosenbergerAuthor Commented:
That did the trick!  Thanks!
0
HLRosenbergerAuthor Commented:
drypz:

On how to enable the check box column, "enabled during Edit Mode of your gridview".  Could you provide code example?  I'm new to .NET...
0
HLRosenbergerAuthor Commented:
drypz:

Also, would you have any info on this:  I have the GridView on a panel, so that I can scroll it.  All controls have that little tab at the upper left.  I want to align the tops of the GridView and the panel.  However, I cannot, visually, move the GridView to align with the top of the panel - that  little tab seems to prevent this.  How can I align the top of the  GridView with the top of the panel?   If you know the answer, I'm open another question, because you should get the credit for it.  
0
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
.NET Programming

From novice to tech pro — start learning today.