AutoGenerateEditButton is ignored in C# code for DetailsView
<p>Edit - Thanks for your replies so far and sorry for not stating exactly what the problem was. The actual markup code is</p>

<pre><code>&lt;asp:DetailsView ID="dvwSomeDetailsView" runat="server" 
  AutoGenerateRows="False" DataSourceID="SomeDataSourceID"&gt;
  &lt;Fields&gt;
    &lt;asp:TemplateField HeaderText="SomeText" SortExpression="SomeText"&gt;
      &lt;EditItemTemplate&gt;
        &lt;cc1:Editor ID="txtDescription" runat="server" 
          Content='&lt;%# Bind("SomeText") %&gt;' /&gt;
      &lt;/EditItemTemplate&gt;
      &lt;ItemTemplate&gt;
        &lt;asp:Label ID="lblDescription" runat="server" 
          Text='&lt;%# Bind"SomeText") %&gt;'&gt;&lt;/asp:Label&gt;
      &lt;/ItemTemplate&gt;
    &lt;/asp:TemplateField&gt;

    &lt;asp:CommandField ButtonType="Image" CancelImageUrl="~/img/cancel.png" 
      EditImageUrl="~/img/edit.png" InsertImageUrl="~/img/insert.png"
      UpdateImageUrl="~/img/save.png" ShowEditButton="True" /&gt;
&lt;/asp:DetailsView&gt;
</code></pre>

<p>I'm not too sure whether setting the ShowEditButton property should be removed, but when I tried to do that I still couldn't set it programmatically.</p>

<p>Now in the code behind file I reduced the Page_Load method to this</p>

<pre><code>protected void Page_Load( object sender, EventArgs e )
{
  dvwSomeDetailsView.AutoGenerateEditButton = true;
}
</code></pre>

<p>What I want to achieve is that by changing the assignment in the Page_Load method I can hide / show the Edit button, but that does not work. When playing around in the markup file I can make the button show up or hide, but I can never change it from the code behind file.</p>

<p>I also tried to explicitly call dvwSomeDetailsView.DataBind after setting the property, but this also didn't work. Overriding OnPreRender and placing the code from the Page_Load method in their didn't do anything to improve this either.</p>

<p>Maybe I'm thinking too complicated - shouldn't there be an easy way to set programmatically whether the button should / shouldn't show?</p>

<p>Thanks in advance for any comments.</p>

<p>Gorgsenegger</p>
