Details view and field edit authorization
<p>I am trying to utilize a details view and provide the edit feature for a few levels of user authorization. Basically level 1 users cannot update a predefined set of fields but level 2 users can update these fields. I had tried simply setting the field to <code>visible=false</code> when defining the <code>EditTemplate</code> and then in the <code>DataBind</code> I would test for authorization and make it <code>visible=true</code> if the user had privileges to update the field (see code example below). Worked like a charm, except I noticed that when level 1 users update the fields they are allowed to update, the <code>visible=false</code> fields would be set to <code>null</code> (overwritten) in the database. So, been trying various options not to have to duplicate the views etc.</p>

<p>code snippet:
aspx....</p>

<pre><code>&lt;asp:TemplateField HeaderText="&lt;%$ Resources:Resource, Level %&gt;" 
    SortExpression="LevelId"&gt;
        &lt;EditItemTemplate&gt;
            &lt;asp:DropDownList ID="LevelList" runat="server" 
                DataTextField="LevelDesc" DataValueField="LevelId"&gt;
             &lt;/asp:DropDownList&gt;
        &lt;/EditItemTemplate&gt;
        &lt;HeaderStyle HorizontalAlign="Right" /&gt;
&lt;/asp:TemplateField&gt;
&lt;asp:TemplateField HeaderText="&lt;%$ Resources:Resource, Level1 %&gt;" 
    SortExpression="Level1Date" Visible="false" &gt;
        &lt;EditItemTemplate&gt;
            &lt;asp:TextBox ID="Level1" runat="server" Text='&lt;%# 
                Bind("Level1Date", "{0:d}") %&gt;'  /&gt;
            &lt;asp:CompareValidator ID="CompareValidator1" runat="server" 
                ErrorMessage="Please enter a valid date (m/d/y)" 
                ControlToValidate="Level1" Operator="DataTypeCheck" 
                Type="Date" Display="Dynamic"&gt;
            &lt;/asp:CompareValidator&gt;
       &lt;/EditItemTemplate&gt;
       &lt;HeaderStyle HorizontalAlign="Right" /&gt;
   &lt;/asp:TemplateField&gt;
   &lt;asp:TemplateField HeaderText="&lt;%$ Resources:Resource, Level2 %&gt;" 
       SortExpression="Level2Date" Visible="false" &gt;
       &lt;EditItemTemplate&gt;
           &lt;asp:TextBox ID="Level2" runat="server" Text='&lt;%# 
               Bind("Level2Date", "{0:d}") %&gt;'  /&gt;
           &lt;asp:CompareValidator ID="CompareValidator2" runat="server" 
               ErrorMessage="Please enter a valid date (m/d/y)" 
               ControlToValidate="Level2" Operator="DataTypeCheck" 
               Type="Date" Display="Dynamic"&gt;
           &lt;/asp:CompareValidator&gt;
       &lt;/EditItemTemplate&gt;
       &lt;HeaderStyle HorizontalAlign="Right" /&gt;
   &lt;/asp:TemplateField&gt;

   &lt;asp:TemplateField HeaderText="&lt;%$ Resources:Resource, Level4 %&gt;" 
       SortExpression="Level4Date" Visible="false" &gt;
       &lt;EditItemTemplate&gt;
           &lt;asp:TextBox ID="Level4" runat="server" Text='&lt;%# 
               Bind("Level4Date", "{0:d}") %&gt;'  /&gt;
 &lt;/Fields&gt;
</code></pre>

<p>aspx.cs SNIPPET</p>

<pre><code>&lt;name&gt;_DataBound(object sender, EventArgs e)
        {
.
.
.
if (User.IsInRole("yyy") || User.IsInRole("xxx))
{
    OfficialProfileInfo.Fields[2].Visible = true;
    OfficialProfileInfo.Fields[3].Visible = true;
}
</code></pre>
