Web >> Development >> ASP.Net >> Database >>  How to do database binding with Repeater control

<%@ Import Namespace="System.Data.OleDb" %> <script runat="server"> sub Page_Load dim dbconn,sql,dbcomm,dbread dbconn=New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;data source=" & server.mappath("demo.mdb")) dbconn.Open() sql="SELECT * FROM addressbook" dbcomm=New OleDbCommand(sql,dbconn) dbread=dbcomm.ExecuteReader() customers.DataSource=dbread customers.DataBind() dbread.Close() dbconn.Close() end sub </script> <body> <form runat="server"> <asp:Repeater id="customers" runat="server"> <HeaderTemplate> <table border="1" width="100%"> <tr bgcolor="#b0c4de"> <th>Name</th> <th>Tel</th> <th>Address</th> </tr> </HeaderTemplate> <ItemTemplate> <tr bgcolor="#f0f0f0"> <td><%#Container.DataItem("name")%> </td> <td><%#Container.DataItem("tel")%> </td> <td><%#Container.DataItem("address")%> </td> </tr> </ItemTemplate> <FooterTemplate> </table> </FooterTemplate> </asp:Repeater> </form> </body> </html> References ========== None