📄 fruit_search.aspx.vb
字号:
Imports System.Data
Imports System.Data.SqlClient
Partial Class fruit_search
Inherits System.Web.UI.Page
#Region " Web 窗体设计器生成的代码 "
'该调用是 Web 窗体设计器所必需的。
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
End Sub
'注意: 以下占位符声明是 Web 窗体设计器所必需的。
'不要删除或移动它。
Private designerPlaceholderDeclaration As System.Object
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: 此方法调用是 Web 窗体设计器所必需的
'不要使用代码编辑器修改它。
InitializeComponent()
End Sub
#End Region
Dim conn As SqlConnection
Dim connectionstring As String
Dim sql, uid, sqlstr As String
Dim mycmd As SqlCommand
Dim getdata As SqlDataReader
Dim da As SqlDataAdapter
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'在此处放置初始化页的用户代码
conn = New SqlConnection(connectionstring)
conn.ConnectionString = "server=HP-PC;Database=SRM;uid=sa;pwd=sa;"
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
End Sub
Private Sub button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button1.Click
BindGrid()
End Sub
Sub MyDataGrid_Page(ByVal sender As Object, ByVal e As DataGridPageChangedEventArgs)
Dim startIndex As Integer
startIndex = MyDataGrid.CurrentPageIndex * MyDataGrid.PageSize
MyDataGrid.CurrentPageIndex = e.NewPageIndex
BindGrid()
End Sub
Sub BindGrid()
Dim ds As DataSet = New DataSet
Dim sign As String = ""
If match.Checked = True Then
sign = "%"
End If
sql = "select * from sci_fruit where 1=1 and " + dropdownlist1.SelectedValue + " like '" + sign + txtContent.Text.ToString.Trim + sign + "' "
Dim adapter As SqlDataAdapter = New SqlDataAdapter(sql, conn)
adapter.Fill(ds)
MyDataGrid.DataSource = ds.Tables(0).DefaultView
MyDataGrid.DataBind()
End Sub
End Class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -