Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not Page.IsPostBack() Then
BindData()
End If
End Sub
Sub BindData()
Dim str As String
str = "SELECT * FROM tb_device"
Dim dt As New DataTable()
dt = connection.QueryDataTable(str)
'*** BindData to GridView ***'
myGridView.DataSource = dt
myGridView.DataBind()
End Sub
Protected Sub myGridView_RowDataBound(ByVal sender As Object, ByVal e As GridViewRowEventArgs)
'*** d_id ***'
Dim lbld_id As Label = CType(e.Row.FindControl("lbld_id"), Label)
If Not IsNothing(lbld_id) Then
lbld_id.Text = e.Row.DataItem("d_id")
End If
'*** d_name ***'
Dim lbld_name As Label = CType(e.Row.FindControl("lbld_name"), Label)
If Not IsNothing(lbld_name) Then
lbld_name.Text = e.Row.DataItem("d_name")
End If
'*** d_serial ***'
Dim lbld_serial As Label = CType(e.Row.FindControl("lbld_serial"), Label)
If Not IsNothing(lbld_serial) Then
lbld_serial.Text = e.Row.DataItem("d_serial")
End If
'*** d_status ***'
Dim lbld_status As Label = CType(e.Row.FindControl("lbld_status"), Label)
If Not IsNothing(lbld_status) Then
lbld_status.Text = e.Row.DataItem("d_status")
End If
End Sub