Private Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView1.RowDataBound
Dim lblCode As Label = CType(e.Row.FindControl("Label1"), Label)
If Not IsNothing(lblCode) Then
lblCode.Text = e.Row.DataItem("Code")
End If
End Sub
Code (VB.NET)
Protected Sub LinkButton2_Click1(ByVal sender As Object, ByVal e As EventArgs)
'ต้องใส่ประมาณไหนครับ
End Sub
Tag : .NET, Ms SQL Server 2005, Web (ASP.NET), VB.NET
Imports System.Data.SqlClient
Public Class Popup3
Inherits System.Web.UI.Page
Dim sql As String = ""
Dim Code As Label
Dim ss As String = ""
Private Sub SelectData()
Sql = "select ROW_NUMBER() OVER(ORDER BY Code) as Row, Code, Name1 From BCAP"
sql &= " where Code LIKE'%" & TextBox1.Text.Trim & "%'OR Name1 LIKE'%" & TextBox1.Text.Trim & "%'"
Dim DT As New DataTable
DT = New ClassConnectDBBC().SelectDB(Sql)
If DT.Rows.Count > 0 Then
GridView1.DataSource = DT
GridView1.DataBind()
End If
End Sub
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Session("UseStarting") = Nothing Then
Response.Redirect("~/UserAccount/LoginDB.aspx", True)
Else
Me.SelectData()
End If
End Sub
Protected Sub LinkButton1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles LinkButton1.Click
Me.SelectData()
End Sub
Private Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView1.RowDataBound
Dim lblCode As Label = CType(e.Row.FindControl("Label1"), Label)
If Not IsNothing(lblCode) Then
lblCode.Text = e.Row.DataItem("Code")
End If
End Sub
Private Sub GridView1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles GridView1.SelectedIndexChanged
Code.Text = CType(GridView1.SelectedRow.Cells(2).FindControl("Label1"), Label).Text.ToString
ss = Code.Text
End Sub
Protected Sub LinkButton2_Click1(ByVal sender As Object, ByVal e As EventArgs)
MsgBox(ss)
End Sub
End Class
Sub modSelectCommand(ByVal sender As Object, ByVal e As GridViewSelectEventArgs)
Session("Re_Code") = GridView1.DataKeys.Item(e.NewSelectedIndex).Value
End Sub