Hiding columns in GridView Control

G

Guest

Hi,
I have binded a dataset to a gridview control at run time.
I'm fetching 5 columns from the database.
But while displaying it on the screen i want to show only 3 columns.
I tried with gridview.columns(i).visible property,but it did't work.

Thanks in advance
Srinivas
 
G

Guest

Hi,
Thanks for the response.
I DID NOT ADD ANY COLUMNS TO THE GRID VIEW AT DESIGN TIME OR AT RUN TIME.
In the codebehind i'm just setting the datasource of the grid view as
dataset which contains 5 columns of data.I require all 5 columns of data ,
but while displaying it i want to hide some columns.

Thanks
Srinivas
 
G

Guest

Hi Winista
Thanks for the URL.
But i'm using ASP.net gridview.
The code that;s given in that url does't fit for it.

Thanks
Srinivas
 
W

Winista

The same approach works for GridView. GridView also has RowDataBound and
RowCreated events and you will use the same technique to remove the cell
from row.
 
Joined
Apr 17, 2009
Messages
1
Reaction score
0
you can write this code in RowCreated Event of Gridview, assuming you want to hide first column

e.Row.Cells[1].Visible = false;

=?Utf-8?B?c3Jpbml2YXM=?= said:
Hi,
I have binded a dataset to a gridview control at run time.
I'm fetching 5 columns from the database.
But while displaying it on the screen i want to show only 3 columns.
I tried with gridview.columns(i).visible property,but it did't work.

Thanks in advance
Srinivas
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,813
Latest member
lawrwtwinkle111

Latest Threads

Top