<%@ 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)
	    	bind
	    end if	
  	End Sub
    	Sub Bind()
	    '设置DataSetCommand
	    SQL = "select * from Groups"
	    myCommand = New OleDbDataAdapter(SQL, myConnection)
	    '使用DataSetCommand的Fill方法来填充dataset
	    myCommand.Fill(ds, "Groups")
	    list1.DataSource=ds.Tables("Groups").DefaultView
	    list1.DataBind()
	    rb.DataSource=ds.Tables("Groups").DefaultView
	    rb.DataBind()
	    dl.DataSource=ds.Tables("Groups").DefaultView
	    dl.DataBind()
    	End Sub
    	Sub SubmitBtn_Click(sender As Object, e As EventArgs)
	     Dim s as string
	     s = s + "----选定 DropDownList : " + dl.SelectedItem.Text     
	     Label1.Text = s 
	  
       End Sub
    </script>
    <body>
       <h3><font face="Verdana">绑定控件</font></h3>
       <form  runat=server>
          <asp:ListBox id="List1" DataTextField = "code_display" DataValueField = "code_value" runat="server"/>
	 <hr>
	 <ASP:radiobuttonList 
	     repeatcolumns="4" repeatdirection="horizontal" repeatlayout="table"
	     id="rb" datatextfield="code_display" DataValueField="code_value" runat="server"/>
	 <hr>
	  <asp:DropDownList id="dl" DataTextField = "code_display" DataValueField = "code_value" runat="server"/>
         <hr>
          <asp:button Text="提交" OnClick="SubmitBtn_Click" runat=server/>
	  <asp:Label id=Label1 font-name="Verdana" font-size="10pt" runat="server" />
       </form>
    </body>
</html>
