removing a buttoncolumn from a datagrid at Page_load determined by an if statement

Posted on 2006-11-13
Last Modified: 2013-11-13
I want to remove the columns for "edit" and "delete" from my datagrid if a condition exist during the page_load using c# in
Question by:kwcowboy1226
  • 2

Accepted Solution

DonKyles earned 500 total points
ID: 17933652
GridView1.Columns[editColumn].Visible = false;
GridView1.Columns[deleteColumn].Visible = false;  

Author Comment

ID: 17933804
Ok, I used your generic name for editColumn and "Edit" but that column is a buttoncolumn with a updatetext, canceltext, and edittext.  The delete column has a commandname and text.  I used "edit" and "delete" and it didn't work.

Expert Comment

ID: 17933900
editColumn/deleteColumn is the column index number

for example
edit  |  delete  |    ID    |     Name    |        Type          |

the editColumn = 0
and deleteColumn = 1

so the code would be

GridView1.Columns[0].Visible = false;
GridView1.Columns[1].Visible = false;  

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will show, step by step, how to integrate R code into a R Sweave document
Displaying an arrayList in a listView using the default adapter is rarely the best solution. To get full control of your display data, and to be able to refresh it after editing, requires the use of a custom adapter.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

914 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now