title: Conditional Logic for Gridview ItemTemplate (using mark up only)
body: <p>I have a gridview as shown below. When the EmpType is contract the EmpID must be masked as "XXX";  for regular employees, actual EmpID should be shown. Also, when it is masked, I need to add a <strong>button control</strong> in the EmpID column.</p>
  
  <p>I need to do it using <strong>mark-up</strong>; not using code behind. How can we write the conditional logic for Gridview's ItemTemplate for this logic?</p>
  
  <p>Note: .Net 4.0</p>
  
  <pre><code>    &lt;asp:GridView ID="Gridview1" runat="server" AutoGenerateColumns="False"&gt;
          &lt;Columns&gt;
              &lt;asp:BoundField HeaderText="AssociateID" DataField="AssociateID" /&gt;
              &lt;asp:TemplateField HeaderText="EmpID"&gt;
                  &lt;ItemTemplate&gt;
                      &lt;%# Eval("EmpID")%&gt;
                  &lt;/ItemTemplate&gt;
              &lt;/asp:TemplateField&gt;
              &lt;asp:BoundField HeaderText="EmpType" DataField="EmpType" /&gt;
          &lt;/Columns&gt;
      &lt;/asp:GridView&gt;
  </code></pre>
  
  <p>CODE BEHIND</p>
  
  <pre><code>    List&lt;Associate&gt; associatesList = new List&lt;Associate&gt;();
      associatesList.Add(new Associate { AssociateID = 1, EmpID = 101, EmpType = "Contract" });
      associatesList.Add(new Associate { AssociateID = 2, EmpID = 102, EmpType = "Regular" });
      Gridview1.DataSource = associatesList;
      Gridview1.DataBind();
  </code></pre>