Imports System.DataImports System.Data.Oledb
Public Class Webform4 inherits System.Web.ui.page
#Region "The code" of the web form designer "
'This call is required for the web form designer.
End Sub Protected WithEvents DataGrid1 As System.Web.UI.WebControls.DataGrid Protected WithEvents Button1 As System.Web.UI.WebControls.Button Protected WithEvents DropDownList1 As System.Web.UI.WebControls.DropDownList
'Note: The following placeholders declare are required by the web form designer. 'Don't delete or move it. Private DesignerPlaceHolderDeclaration as System.Object
Private Sub Page_init (Byval E AS System.EventArgs) Handles mybase.init 'Codegen: This method call is required by the Web Form Designer' Do not modify it using the code editor. InitializationComponent () End Sub
#End region
Private sub page_load (Byval e AS System.EventArgs) Handles mybase.load if not ispostback kiln
Private Sub Button1_Click (ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Response.Write (DropDownList1.SelectedItem.Value) Dim myconnection As OleDbConnection = New OleDbConnection ( "Provider = Microsoft.Jet.OLEDB.4.0 ; Data Source = "& Server.MapPath (" aspnet.mdb ")) Dim myadapter As OleDbDataAdapter = New OleDbDataAdapter (" select * from student where id = " DropDownList1.SelectedItem.Value.ToString, myconnection) Dim mydataset As DataSet = new DataSet myadapter.Fill (mydataset, "student") Dim mybuilder As OleDbCommandBuilder = new OleDbCommandBuilder (myadapter) mydataset.Tables ( "student"). Rows (0) .Delete () myadapter.Update (mydataset, "student") mydatashow () End SubPrivate Function mydatashow () Dim myconnection As OleDbConnection = New OleDbConnection ( "Provider = Microsoft.Jet.OLEDB.4.0; Data Source =" & Server.MapPath ( "aspnet.mdb")) Dim myadapter As OleDbDataAdapter = New OleDbDataAd apter ( "select * from student", myconnection) Dim mydataset As DataSet = New DataSet myadapter.Fill (mydataset, "student") DataGrid1.DataSource = mydataset.Tables ( "student"). DefaultView DataGrid1.DataBind () DropDownList1.DataSource = MyDataSet.Tables ("student"). DefaultView DropdownList1.DataTextField = "ID" DROPDOWNLIST1.DATAVALUEFIELD = "ID" DROPDOWNLIST1.DATABIND () MyConnection.Close () end functionend Class