Click here to Skip to main content
15,897,187 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hello
How can (web in C#)?
Hide a column in a gridView that is filled with dataBase
Note:
The database is filled with the GridView.
GridView columns at run time are denoted.
So، before you run ، the column not known.
Posted
Updated 7-Feb-12 22:11pm
v2
Comments
Aniket Yadav 7-Feb-12 8:17am    
Will You Please Elaborate Little More So That I Can Help You

try this code

Code Behinde
C#
GridView1.DataBind();
        if (GridView1.Columns.Count > 0)
            GridView1.Columns[0].Visible = false;
        else
        {
            GridView1.HeaderRow.Cells[0].Visible = false;
            foreach (GridViewRow gvr in GridView1.Rows)
            {
                gvr.Cells[0].Visible = false;
            }
        }



please vote if this will help
 
Share this answer
 
This is a winforms app, or a web app ? I think we need to see the code, but, broadly, the way you hide a column is to specify the columns you want to show instead of having it show them all. I would assume that you could do that programatically on the fly from a dynamic data source. The only other way I could see, is to hide the column by resizing it.
 
Share this answer
 
Thank you
I am working with the web.
GridView DataSource is not connected to sqlDataSource.
But I have a stored procedure in the code it works.
So your code does not work when the GridView column number of zero indicates.
Program number is zero GridView columns.
--------------------------------------------
The summary: We storedprocedure parameter and value that we have written in the GridView to select storedprocedure.
GridView will include seven columns that we will not show the seventh column.
 
Share this answer
 
Comments
zyck 8-Feb-12 4:03am    
hi alireza pls vote if this will help
thanks

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900