title: Strongly-typed or weakly-typed binding in codebehind in front end?
body: <p>So my question is more in relation to what people consider to be the best practice and why:</p>
  
  <p>I've been dropping literals into pages and repeaters and binding them in code behind for a while. Is this considered bad practice?
  ie:</p>
  
  <p>ASPX Page:</p>
  
  <pre><code>&lt;asp: Literal id="litTextToInsert" runat="Server" /&gt;
  </code></pre>
  
  <p>Code Behind:</p>
  
  <pre><code>litTextToInsert.Text = objData.MyText;
  </code></pre>
  
  <p>OR (repeater):</p>
  
  <pre><code>protected void rpt_ItemDataBoundVersion(object sender, RepeaterItemEventArgs e)
  {
      if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
      {
          RepeaterItem objItem = e.Item;
          Data.MyObject objDataItem = (Data.MyObject) objItem.DataItem;
          Literal litMyText= (Literal)objItem.FindControl("litTextToInsert");
          litMyText = objDataItem.MyText;               
      }
  }
  </code></pre>
  
  <p>With most demos about MVC and general WebForms i see a lot of people simply dropping binding code into the front end</p>
  
  <p>ie:</p>
  
  <p>ASPX Page:</p>
  
  <pre><code>&lt;%#Eval("MyText") %&gt;
  </code></pre>
  
  <p>I personally dont like doing this as i find it makes it harder for me to know if someone changed the field name, or mis typed it during development - the other way you won't know until the page loads.</p>
  
  <p>With the strongly typed version if something changes in your DAL etc the build will break - letting me know I've messed up.</p>
  
  <p>Why do so many people <em>appear</em> to use weakly typed code in ASP.Net (in examples, MVC, etc)?
  Am i missing something? 
  Am i an idiot and missing the point? 
  Is this just because its demo code attempting to be simpler? </p>
  
  <p>Let me know.</p>