📄 defaultvb.aspx.vb
字号:
Imports System
Imports System.Data
Imports System.Data.OleDb
Imports System.Web.UI
Imports System.IO
Imports System.Web.UI.WebControls
Imports Telerik.QuickStart
Namespace Telerik.ComboboxExamplesVB.Templates
'/ <summary>
'/ Summary description for _Default.
'/ </summary>
Public Class DefaultVB
Inherits XhtmlPage
Protected DataGrid1 As System.Web.UI.WebControls.DataGrid
Protected RadComboBox1 As Telerik.WebControls.RadComboBox
Protected RadComboBox2 As Telerik.WebControls.RadComboBox
Protected RadComboBox3 As Telerik.WebControls.RadComboBox
Private Function FormatDate([date] As DateTime) As String
Return [String].Format("{0}/{1}/{2}", [date].Year, [date].Month, [date].Day)
End Function 'FormatDate
Private Sub Page_Load(sender As Object, e As System.EventArgs) Handles MyBase.Load
LoadSupervisors()
End Sub 'Page_Load
Private Sub LoadSupervisors()
Dim mdbPath As String = Server.MapPath("~/Combobox/Data/NWind.mdb")
Dim dbCon As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + mdbPath)
dbCon.Open()
Dim sql As String = "SELECT * from Employees"
Dim adapter As New OleDbDataAdapter(sql, dbCon)
Dim dt As New DataTable()
adapter.Fill(dt)
dbCon.Close()
Dim grid As DataGrid = CType(RadComboBox3.SelectedItem.FindControl("SupervisorGrid"), DataGrid)
grid.DataSource = dt
grid.DataBind()
End Sub 'LoadSupervisors
Protected Sub FromMonthChanged(sender As Object, e As MonthChangedEventArgs)
RadComboBox1.OpenDropDownOnLoad = True
RadComboBox2.OpenDropDownOnLoad = False
End Sub 'FromMonthChanged
Protected Sub FromDateChanged(sender As Object, e As System.EventArgs)
Dim calendar As Calendar = CType(RadComboBox1.SelectedItem.FindControl("Calendar1"), Calendar)
RadComboBox1.Text = FormatDate(calendar.SelectedDate)
RadComboBox1.OpenDropDownOnLoad = False
End Sub 'FromDateChanged
Protected Sub ToMonthChanged(sender As Object, e As MonthChangedEventArgs)
RadComboBox1.OpenDropDownOnLoad = False
RadComboBox2.OpenDropDownOnLoad = True
End Sub 'ToMonthChanged
Protected Sub ToDateChanged(sender As Object, e As System.EventArgs)
Dim calendar As Calendar = CType(RadComboBox2.SelectedItem.FindControl("Calendar2"), Calendar)
RadComboBox2.Text = FormatDate(calendar.SelectedDate)
RadComboBox2.OpenDropDownOnLoad = False
End Sub 'ToDateChanged
' Fixing the calendar control XHTML output.
Protected Overrides Sub Render(writer As HtmlTextWriter)
Dim stringWriter As New StringWriter()
Dim newWriter As New HtmlTextWriter(stringWriter)
MyBase.Render(newWriter)
Dim pageHtml As String = stringWriter.ToString()
pageHtml = pageHtml.Replace("<td align=""Center""", "<td align=""center""")
pageHtml = pageHtml.Replace("<td align=""Right""", "<td align=""right""")
pageHtml = pageHtml.Replace("<td align=""Left""", "<td align=""left""")
writer.Write(pageHtml)
End Sub 'Render
Protected Overrides Sub OnInit(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 Class 'DefaultVB
End Namespace 'Telerik.ComboboxExamplesVB.Templates
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -