title: Binding a text box value with condition in aspx page
body: <p>I am using asp form view. I want to bind a text box value based on condition.</p>
  
  <pre><code>&lt;td style="height: 12px; 
              border-right: silver 1px solid; 
              border-top: silver 1px solid;
              border-left: silver 1px solid; 
              border-bottom: silver 1px solid;"&gt;
  
      &lt;asp:TextBox ID="txtHaulZoneCodeLEM" 
              runat="server" 
              CssClass="cagText" 
              Text='&lt;%# Bind("HaulZoneCodeLEM") %&gt;'&gt;
      &lt;/asp:TextBox&gt;
  
  &lt;/td&gt;
  </code></pre>
  
  <p>I have tried this: </p>
  
  <pre><code>&lt;asp:TextBox 
      ID="txtHaulZoneCodeLEM" 
      runat="server" 
      CssClass="cagText" 
      Text='&lt;%# ((TextBox) Container.DataItem).HaulZoneCodeLEM != 0 ? ((TextBox) Container.DataItem).HaulZoneCodeLEM : string.Empty %&gt;'&gt;
  </code></pre>
  
  <p>How to resolve this?</p>
  
  <p>I moved to code behind : </p>
  
  <pre><code> &lt;td style="height: 12px; border-right: silver 1px solid; border-top: silver 1px solid;
                                          border-left: silver 1px solid; width: 339px; border-bottom: silver 1px solid;"&gt;
  
         &lt;asp:TextBox ID="txtHaulZoneCodeLEM" runat="server" CssClass="cagText" Text=ConvertHaulZoneCodeForDisplay('&lt;%# Bind("HaulZoneCodeLEM") %&gt;')&gt;                      
                                          &lt;/asp:TextBox&gt;
  
                                      &lt;/td&gt;
  </code></pre>
  
  <p>In My code behind page I wrote like this : </p>
  
  <pre><code> Protected Function ConvertHaulZoneCodeForDisplay(ByVal str As String) As String
          If str = 0 Then Return ""
      End Function
  End Class
  </code></pre>
  
  <p>Still I am getting error in the aspx page..</p>