⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 defaultvb.aspx.vb

📁 Telerik是很大的第三方软件制造商
💻 VB
字号:

Imports System
Imports System.Data
Imports System.Drawing
Imports System.Web
Imports System.Web.UI.WebControls
Imports System.Web.UI.HtmlControls
Imports Telerik.WebControls
Imports System.Data.OleDb
Imports Telerik.QuickStart


Namespace Telerik.CallbackExamplesVB.Controls.ListBox
    '/ <summary>
    '/ Summary description for _Default.
    '/ </summary>

    Public Class DefaultVB
        Inherits XhtmlPage
        Protected WithEvents lbContinents As Telerik.WebControls.CallbackListBox
        Protected WithEvents lbCountries As Telerik.WebControls.CallbackListBox
        Protected Label1 As System.Web.UI.WebControls.Label
        Protected Label2 As System.Web.UI.WebControls.Label
        Protected Label3 As System.Web.UI.WebControls.Label
        Protected WithEvents label11 As System.Web.UI.WebControls.Label
        Protected WithEvents statusLabel As System.Web.UI.WebControls.Label
        Protected lbTowns As Telerik.WebControls.CallbackListBox


        Private Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
            If Not Page.IsPostBack Then
                LoadContinents()
            End If
        End Sub 'Page_Load

#Region "Web Form Designer generated code"

        Protected Overrides Sub OnInit(ByVal e As EventArgs)
            '
            ' CODEGEN: This call is required by the ASP.NET Web Form Designer.
            '
            InitializeComponent()
            MyBase.OnInit(e)
        End Sub 'OnInit


        '/            Required method for Designer support - do not modify
        '/            the contents of this method with the code editor.
        '/ </summary>
        Private Sub InitializeComponent()

        End Sub 'InitializeComponent

#End Region


        Private Sub LoadContinents()
            Dim path As String = Server.MapPath("~/Callback/Data/Countries.mdb")
            Dim dbCon As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + path)
            dbCon.Open()

            Dim adapter As New OleDbDataAdapter("SELECT * FROM Continents", dbCon)
            Dim dt As New DataTable()
            adapter.Fill(dt)
            dbCon.Close()

            lbContinents.DataTextField = "Name"
            lbContinents.DataValueField = "ID"
            lbContinents.DataSource = dt
            lbContinents.DataBind()

            If lbContinents.SelectedIndex = -1 Then
                lbContinents.SelectedIndex = 0
                LoadCountries(lbContinents.Items(0).Value)
            End If
        End Sub 'LoadContinents


        Private Sub LoadCountries(ByVal continentID As String)
            Dim path As String = Server.MapPath("~/Callback/Data/Countries.mdb")
            Dim dbCon As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + path)
            dbCon.Open()

            Dim adapter As New OleDbDataAdapter("SELECT * FROM Countries WHERE ContinentID=" + continentID + "", dbCon)
            Dim dt As New DataTable()
            adapter.Fill(dt)
            dbCon.Close()

            lbCountries.DataTextField = "Name"
            lbCountries.DataValueField = "ID"
            lbCountries.DataSource = dt
            lbCountries.DataBind()

            lbCountries.SelectedIndex = 0
            LoadCities(lbCountries.Items(0).Value)
        End Sub 'LoadCountries



        Private Sub LoadCities(ByVal countryID As String)
            Dim path As String = Server.MapPath("~/Callback/Data/Countries.mdb")
            Dim dbCon As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + path)
            dbCon.Open()

            Dim adapter As New OleDbDataAdapter("SELECT * FROM Cities WHERE CountryID=" + countryID, dbCon)
            Dim dt As New DataTable()
            adapter.Fill(dt)
            dbCon.Close()

            lbTowns.DataTextField = "Name"
            lbTowns.DataValueField = "ID"
            lbTowns.DataSource = dt
            lbTowns.DataBind()

            If lbTowns.SelectedIndex = -1 Then
                lbTowns.SelectedIndex = 0
            End If
        End Sub 'LoadCities


        Private Sub CallbackDropDownList1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles lbContinents.SelectedIndexChanged
            LoadCountries(lbContinents.SelectedItem.Value)
        End Sub 'CallbackDropDownList1_SelectedIndexChanged


        Private Sub CallbackDropDownList2_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles lbCountries.SelectedIndexChanged
            LoadCities(lbCountries.SelectedItem.Value)
        End Sub 'CallbackDropDownList2_SelectedIndexChanged
    End Class 'DefaultVB 
End Namespace 'Telerik.CallbackExamplesVB.Controls.ListBox 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -