title: asp.net issue populating gridview from mysql
body: <p>So here's my situation. My company bought a product which runs in the cloud. The program is great, but it lacks in it's reporting functions. So we purchased an add-on module to the package which allows us to have read-only access to the data. I planned on using this to create some reports. And yes, I could use something like crystal reports or other report generators to do this, but I have chosen to use my asp.net code. I like it, I'm familiar with it, and for this company it is the most cost effective, and easiest to update solution with my background. </p>
  
  <p>So I'm using a gridview to look at some of the data. Instead of using the 'asp:sqldatasource' to lookup the data, I chose to use the code behind. Once all the data is  bound to the gridview from the code behind I use the 'columns' and 'asp:templatefields' to create layout. In each one of the datarows I use the Eval() method to populate the information.</p>
  
  <p>Here's the problem. The Eval method doesn't seem to recongnize things from it's datasource. The error message 'The server tag is not well formed' is thrown for my asp:labels. What am I missing here.</p>
  
  <p>Here's the asp code:</p>
  
  <pre><code>&lt;asp:GridView ID="OwnerWOS" Width="" Height=""
                  BorderColor="White" EmptyDataText="" EnableViewState="false" GridLines="None" 
                  OnLoad="OwnerWOS_Load" OnDataBinding="OwnerWOS_DataBinding" runat="server"&gt;
      &lt;Columns&gt;
          &lt;asp:Templatefield HeaderText="Service Issue"&gt;
              &lt;ItemTemplate&gt;
                  &lt;asp:label ID="lblIssue" runat="server" Text="&lt;%# Eval("issueid") %&gt;"&gt;&lt;/asp:label&gt;
              &lt;/ItemTemplate&gt;
          &lt;/asp:Templatefield&gt;
          &lt;asp:Templatefield HeaderText="Employee"&gt;
              &lt;ItemTemplate&gt;
                  &lt;asp:label ID="lblEmployee" runat="server" Text="&lt;%# Eval("EMPLOYEE") %&gt;"&gt;&lt;/asp:label&gt;
              &lt;/ItemTemplate&gt;
          &lt;/asp:Templatefield&gt;
          &lt;asp:Templatefield HeaderText="Address"&gt;
              &lt;ItemTemplate&gt;
                  &lt;asp:label ID="lblAddress" runat="server" Text="&lt;%# Eval("name") %&gt;"&gt;&lt;/asp:label&gt;
              &lt;/ItemTemplate&gt;
          &lt;/asp:Templatefield&gt;
          &lt;asp:Templatefield HeaderText="Description"&gt;
              &lt;ItemTemplate&gt;
                  &lt;asp:label ID="lblDesc" runat="server" Text="&lt;%# Eval("street1") %&gt;"&gt;&lt;/asp:label&gt;
              &lt;/ItemTemplate&gt;
          &lt;/asp:Templatefield&gt;
          &lt;asp:Templatefield HeaderText="Work Date"&gt;
              &lt;ItemTemplate&gt;
                  &lt;asp:label ID="lblWorkDate" runat="server" Text="&lt;%# Eval("duedate") %&gt;"&gt;&lt;/asp:label&gt;
              &lt;/ItemTemplate&gt;
          &lt;/asp:Templatefield&gt;
          &lt;asp:Templatefield HeaderText="Time (h)"&gt;
              &lt;ItemTemplate&gt;
                  &lt;asp:label ID="lblTime" runat="server" Text="&lt;%# Eval("owners.name") %&gt;"&gt;&lt;/asp:label&gt;
              &lt;/ItemTemplate&gt;
          &lt;/asp:Templatefield&gt;
          &lt;asp:Templatefield HeaderText="Billed"&gt;
              &lt;ItemTemplate&gt;
                  &lt;asp:Label ID="lblBilled" runat="server" Text="&lt;%# Eval("") %&gt;"  /&gt;
              &lt;/ItemTemplate&gt;
          &lt;/asp:Templatefield&gt;
      &lt;/Columns&gt;
      &lt;HeaderStyle /&gt;
      &lt;FooterStyle /&gt;
      &lt;RowStyle /&gt;
      &lt;SelectedRowStyle /&gt;
      &lt;AlternatingRowStyle /&gt;
      &lt;EditRowStyle /&gt;
  &lt;/asp:GridView&gt;
  </code></pre>
  
  <p>And the Code Behind:</p>
  
  <pre><code>Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
  
      If Not Page.IsPostBack Then
          'Get the first day and last day of this month to pre-populate the date fields
          Dim FirstOfMonth As String = Today.Month.ToString &amp; "/1/" &amp; Today.Year.ToString
          Dim LastOfMonth As String = Today.AddMonths(1).ToString &amp; "/" &amp; Today.AddDays(-1).ToString &amp; "/" &amp; Today.Year.ToString
  
  
          Dim da As New OdbcDataAdapter("SELECT DISTINCT issues.issueid, users.firstname &amp; ' ' &amp; users.lastname AS EMPLOYEE, property.name, " &amp; _
                                                  "property.street1, units.street1, issues.description, issuecategory.name, issues.duedate, issues.hours, owners.name " &amp; _
                                  "FROM ((((((issues RIGHT JOIN (issueproplinks RIGHT JOIN property ON issueproplinks.propid = property.propid) ON issues.issueid = issueproplinks.issueid) " &amp; _
                                                  "LEFT JOIN issuecategory ON issues.categoryid = issuecategory.categoryid) " &amp; _
                                                  "LEFT JOIN issuestatus ON issues.statusid = issuestatus.statusid) " &amp; _
                                                  "LEFT JOIN users ON issues.assignid = users.userid) " &amp;
                                                  "RIGHT JOIN ownerships ON property.propid = ownerships.propid) " &amp; _
                                                  "RIGHT JOIN owners ON ownerships.ownerid = owners.ownerid) " &amp; _
                                                  "LEFT JOIN (issueunitlinks LEFT JOIN units ON issueunitlinks.unitid = units.unitid) ON issues.issueid = issueunitlinks.issueid " &amp; _
                                  "WHERE (((issues.duedate) Between '2/1/2014' And '2/28/2014') AND ((owners.name)='LK Investment Group LLC'))" &amp; _
                                  "ORDER BY issuecategory.name, issues.duedate;", ConfigurationManager.ConnectionStrings("OA").ConnectionString)
          Dim ds As New DataSet()
          da.Fill(ds)
  
          OwnerWOS.DataSource = ds
          OwnerWOS.DataBind()
      End If
  
  
  End Sub
  </code></pre>
  
  <p>Yeah the SQL statement is a bit long for a small output. But it's what I needed to do with the access this company had given me. Also, the SQL statement has been tested and does return the results I expect in other programs.</p>
  
  <p>So in the asp code up top I used a variety of different access methods in the Eval statements, from providing only the name of the field, to providing the full table/field name. I've also tried removing them one at a time to see if any of them would work on their own, but they all produce the same "Malformed tag" event. </p>
  
  <p>Please let me know if you need any additional details. Thanks.</p>