Disabling Columns in GridView


Today I needed to find a way to disable certain columns in a GridView while keeping the Gridview in the same visible state it would be in no matter what authority the user had to the page. I put the following code in the databind section under an if statement that says that if the user is not authorized:

gvCM.Columns[3].Visible = false; // Hides the edit button

gvCM is the name of the GridView and [3] controls the column that I didn’t want to be visible, in this case the forth column which has the edit button.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s