Usando DataList

<< Click to Display Table of Contents >>

Navigation:  ASP.NET > ASP Controls >

Usando DataList

Previous pageReturn to chapter overviewNext page

aspx

 

            <asp:DataList ID="myDataList" runat="server" GridLines="Both">

                <HeaderTemplate>

                    <td><b>Dia</b></td>

                    <td><b>Entrada 1</b></td>

                    <td><b>Saída 1</b></td>

                    <td><b>Entrada 2</b></td>

                    <td><b>Saída 2</b></td>

                </HeaderTemplate>

                <ItemTemplate>

                    <td>

                        <%# DataBinder.Eval(Container.DataItem,"dia") %>

                    </td>

                    <td>

                        <%# DataBinder.Eval(Container.DataItem,"myColuna1")%>

                    </td>

                    <td>

                        <%# DataBinder.Eval(Container.DataItem,"myColuna2")%>

                    </td>

                    <td>

                        <%# DataBinder.Eval(Container.DataItem,"myColuna3")%>

                    </td>

                    <td>

                        <%# DataBinder.Eval(Container.DataItem,"myColuna3")%>

                    </td>

                </ItemTemplate>

            </asp:DataList>

 

 

C#

 

           // ..........   

           readCommand.CommandText = "select dia, myColuna1, myColuna2, myColuna3, myColuna4 from cargahor";

 

            try

            {

                DataListBatidas.DataSource = readCommand.ExecuteReader();

                DataListBatidas.DataBind();

            }

            catch (Exception ex)

            {

                Response.Write("<b>" + ex.Message + "</b><br /><br />" + readCommand.CommandText + "<br /><br />");

            }