[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 259
  • Last Modified:

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

I want to remove the columns for "edit" and "delete" from my datagrid if a condition exist during the page_load using c# in asp.net.
0
kwcowboy1226
Asked:
kwcowboy1226
  • 2
1 Solution
 
DonKylesCommented:
GridView1.Columns[editColumn].Visible = false;
GridView1.Columns[deleteColumn].Visible = false;  
0
 
kwcowboy1226Author Commented:
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.
0
 
DonKylesCommented:
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;  
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now