Bind Dummy DataTable To ASP Repeater


protected void Page_Load(object sender, EventArgs e)
    {
        DataTable dt = new DataTable("Personal Database");
        dt.Columns.Add("Name", typeof(string));
        dt.Columns.Add("Age", typeof(Int32));
        dt.Columns.Add("Designation", typeof(string));
        dt.Columns.Add("Email", typeof(string));
        dt.Rows.Add(new string[3] { "Jack", 24, ".net Programmer"});
        dt.Rows.Add(new string[3] { "Jill", 23, ".net Programmer"});
        Repeater1.DataSource = dt;
        Repeater1.DataBind();
    }



    <asp:Repeater ID="Repeater1" runat="server">
        <HeaderTemplate>
            <table width="100%" border="0" cellspacing="0">
                <tr>
                    <td colspan="2">
                        <b>Personal Database</b>
                    </td>
                </tr>
        </HeaderTemplate>
        <ItemTemplate>
            <tr>
                <td style="background-color: inherit;" colspan="2">
                    <%# DataBinder.Eval(Container, "DataItem.Name") %>
                </td>
            </tr>
            <tr>
                <td>
                    <%# DataBinder.Eval(Container, "DataItem.Age") %>
                </td>
                <td>
                    <%# DataBinder.Eval(Container, "DataItem.Designation") %>
                </td>
            </tr>
        </ItemTemplate>
        <FooterTemplate>
            </table>
        </FooterTemplate>
    </asp:Repeater>

Related Posts Plugin for WordPress, Blogger...