0

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>
3
Contributors
3
Replies
7
Views
5 Years
Discussion Span
Last Post by sufyan2011
0

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,

0

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>
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.