<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OleDb" %>
<html>
    <script language="VB" runat="server">
	Dim myConnection As OleDbConnection
	Dim myCommand    As OleDbDataAdapter
	Dim ds           As New DataSet
	Dim ConnStr      As String
	Dim SQL          As String
	Sub Page_Load(Source As Object, E As EventArgs) 
	   ConnStr = "Provider=SQLOLEDB; Data Source=(local); Initial Catalog=ASPNET;User ID=sa;"
	   myConnection = New OleDbConnection(ConnStr)      
	    if NOT (isPostBack)
	    	rebind
	    end if	
  	End Sub
    	Sub ReBind()
	    '定义DataSetCommand
	    SQL = "select * from Groups"
	    myCommand = New OleDbDataAdapter(SQL, myConnection)
	    '使用DataSetCommand的Fill方法来填充DataSet
	    myCommand.Fill(ds, "Groups")
	    '绑定DataGrid	
	    DataGrid1.DataSource=ds.Tables("Groups").DefaultView
	    DataGrid1.DataBind()
    	End Sub
    </script>
    <body>
       <h3><font face="Verdana"> Data Repeater</font></h3>
     <form  runat=server>
   	<asp:Repeater id="DataGrid1" runat="server">
	  <HeaderTemplate>
	    <table border = 1>
	      <tr>
		<td><b>姓名</b></td>
		<td><b>组</b></td>
		<td><b>类型</b></td>
	      </tr>
	  </HeaderTemplate>
	  <ItemTemplate>
	     <tr>
	           <td> <%# Container.DataItem("code_display") %></td>
	           <td><%# Container.DataItem("code_category") %></td>
	           <td><%# Container.DataItem("type") %></td>
	    </tr>
	  </ItemTemplate>
	  <AlternatingItemTemplate>
	    <tr style="background-color: silver"> 
		   <td> <%# Container.DataItem("code_display") %></td>
		   <td><%# Container.DataItem("code_category") %></td>
		   <td><%# Container.DataItem("type") %></td>
	    </tr>
	  </AlternatingItemTemplate>
	  <FooterTemplate>
	    </table>
	  </FooterTemplate>
	</asp:Repeater>
       </form>
    </body>
</html>
