How do I populate data in both tablefoot and tablebody by getting values from an sql database. For example, the data in tablefoot refers to the date and tablebody refers to the values that belong to that date. I am confused about how this kind of tables work. Thanks in advance!

<table id="data">
            <tfoot id="datafoot">
                <tr>
                    <th>1</th>
                    <th>2</th>
                    <th>3</th>
                    <th>4</th>
                    <th>5</th>
                </tr>
            </tfoot>
            <tbody>
                <tr>
                    <td>1</td>
                    <td>25</td>
                    <td>27</td>
                    <td>25</td>
                    <td>54</td>
                </tr>
            </tbody>
        </table>

Hi,
You can use a repeater control to do this. It has header, footer, item and alternatingItem templates that you can store the database info in.
First use a dataAdapter to populate a dataTable, then set the dataTable as the data source of the repeater control and dataBind it.

Then use your repeater in the aspx page to pull through the data:

<asp:repeater id="repeater1" runat="server">
  <itemTemplate>
    <tr>
       <td><%#Container.DataItem("columnName1")%></td>
       <td><%#Container.DataItem("columnName2")%></td>
    </tr>
  </itemTemplate>
</asp:repeater>

You can alternatingItemTemplate to use a different css class if you want to highlight the rows to make them stand out.

Hope that helps,

I put this in my code. It still won't work :/

MyCmd = New SqlCommand("getChartStats", MyConn)
        MyCmd.CommandType = CommandType.StoredProcedure
        MyCmd.Connection = MyConn
        da = New SqlDataAdapter(MyCmd)
        data = New DataSet()
        da.Fill(data)
        statsChart.DataSource = data.Tables(0)
        statsChart.DataBind()


and 


<asp:Repeater ID="statsChart" runat="server" > 
           <ItemTemplate>
                   <td><%# Eval("TotalEnergy")%></td>
           </ItemTemplate> 
</asp:Repeater>

please specify the error message.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.