title: How can I disable/hide edit button in gridview control of ASP.net
body: <p>I have a gridview control in which there are two command buttons (linkButton), one is "select" and the other is "edit", now I have a session variable named as department and it contains values like "WRITING", "EDITING", "ADMIN" etc... Now the thing is I want the edit button to disappear when the department is "WRITING" but when it is "EDITING" or "ADMIN" I want edit button appear.</p>
  
  <p>I was searching some forums for this problem and found this </p>
  
  <pre><code>row.Cells[0].Controls.Clear();
  </code></pre>
  
  <p>The problem with this code is that it hides the entire command column including "select" and "edit" buttons while I only want to control "edit" button, select should remain visible for all departments.</p>
  
  <p>if I do it like (on row data bound event)</p>
  
  <pre><code>e.row.Cells[0].Controls[1].visible = false OR
  e.row.Cells[0].Controls[0].visible = false
  </code></pre>
  
  <p>Specified argument was out of the range of valid values.</p>
  
  <p>How can I do this properly ?</p>
  
  <p>Thanks.</p>