<%@ Page Language="vb" Debug="true" %> <%@ Import Namespace =Namespace="System.Data" %> <%@ Import Namespace =Namespace="System.Data.OleDb" %> <script language="VB" runat="server"> dim MyConnection as OleDbConnection
dim cmdSelect as OleDbCommand
dim dtrReader as OleDbDataReader
Sub Page_load()Sub Page_load(sender asobject,e as Eventargs)
MyConnection =New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source ="+ Server.MapPath(".")+"/db/data.mdb")
ifnot IsPostBack() then dropSMALL.Visible="false" dropBig_BindGrid()
endif End Sub Sub dropBig_BindGrid()Sub dropBig_BindGrid()
CmdSelect=new OleDbCommand("SELECT * FROM [big] ORDER BY b_id ASC",MyConnection)
MyConnection.Open()
dtrReader=CmdSelect.ExecuteReader()
dropBIG.DataSource=dtrReader
dropBIG.DataTextField="b_name" dropBIG.DataValueField="b_id" dropBIG.DataBind()
dropBIG.Items.Insert(0,new ListItem("Select",-1))
dtrReader.Close()
MyConnection.Close()
End Sub Sub dropBIG_Changed()Sub dropBIG_Changed(s asObject,e as EventArgs)
dim i asinteger= dropBIG.SelectedItem.value
If i =-1then WrongBigclass.text="Select!" dropSMALL.Visible="false" Else dropSMALL.Visible="true" WrongBigclass.text="" dropSMALL_BindGrid( i )
EndIf End Sub Sub dropSMALL_BindGrid()Sub dropSMALL_BindGrid( j )
CmdSelect=new OleDbCommand("SELECT * FROM [small] WHERE b_ID= "& j &" ORDER BY s_id ASC",MyConnection)
MyConnection.Open()
dtrReader=CmdSelect.ExecuteReader()
dropSMALL.DataSource=dtrReader
dropSMALL.DataTextField="s_name" dropSMALL.DataValueField="s_id" dropSMALL.DataBind()
dtrReader.Close()
MyConnection.Close()
End Sub Sub Button_Click()Sub Button_Click(s asObject,e as EventArgs)
If dropBIG.SelectedItem.value <>-1then info.text = ("BIG_id:"& dropBIG.SelectedItem.value &"<BR>"&"BIG_name:"& dropBIG.SelectedItem.text &"<BR>"&"SMALL_id:"& dropSMALL.SelectedItem.value &"<BR>"&"SMALL_name:"& dropSMALL.SelectedItem.text )
Else WrongBigclass.text="Selected!" EndIf End Sub </Script> <Form runat="server"> <asp:dropdownlist id="dropBIG" AutoPostBack="true" OnSelectedIndexChanged="dropBIG_Changed" runat="server"/> <asp:dropdownlist id="dropSMALL" AutoPostBack="true" runat="server"/><BR> <asp:Button id="btnClick" Text="SELECT" OnClick="Button_Click" Runat="server"/><BR> <asp:Label id="WrongBigclass" forecolor="#CC0000" runat="server" enableviewstate="false"/> <asp:Label id="info" forecolor="#CC0000" runat="server" enableviewstate="false"/> </Form>