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">

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">

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()
        statsChart.DataSource = data.Tables(0)


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

please specify the error message.