Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'在此处放置初始化页的用户代码
If Not IsPostBack Then
Bind()
End If
End Sub
Private Sub Bind()
Dim conn As New System.Data.SqlClient.SqlConnection(System.Configuration.ConfigurationSettings.AppSettings("WorkLogDB"))
Dim comm As New System.Data.SqlClient.SqlCommand
Dim ds As New DataSet
Dim adapter As New System.Data.SqlClient.SqlDataAdapter(comm)
With comm
.Connection = conn
.CommandText = " Select UserName From [User] "
adapter.SelectCommand = comm
.Connection.Open()
adapter.Fill(ds)
Me.DataGrid1.DataSource = ds.Tables(0).DefaultView
Me.DataGrid1.DataBind()
.Connection.Close()
End With
End Sub
Private Sub DataGrid1_ItemCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles DataGrid1.ItemCommand
Select Case e.CommandName.ToUpper
Case "link".ToUpper
Me.Label1.Text = e.Item.Cells(0).Text