Partial Class _Default
Inherits System.Web.UI.Page
Private Sub BtnEdit_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Dim tmpbtn As Button = sender
Console.WriteLine(tmpbtn.ID)
End Sub
Private Sub BtnDelete_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Dim tmpbtn As Button = sender
Console.WriteLine(tmpbtn.ID)
End Sub
Protected Sub Search_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Search.Click
Try
Dim numrows As Integer = CInt(5)
Dim numcells As Integer = CInt(3)
Dim i As Integer = 0
Dim j As Integer = 0
Dim Row As Integer = 0
Dim r As HtmlTableRow
Dim c As HtmlTableCell
For j = 0 To numrows - 1
r = New HtmlTableRow()
If (Row Mod 2 <> 0) Then r.BgColor = "#C6ECFF"
Row += 1
'----ลำดับที่ ----
c = New HtmlTableCell()
c.Controls.Add(New LiteralControl(j + 1))
r.Cells.Add(c)
'----ชื่อสกุล ----
c = New HtmlTableCell()
c.Controls.Add(New LiteralControl("ชื่อ-สกุล" & j))
r.Cells.Add(c)
'---- แก้ไขรายการ ----
c = New HtmlTableCell()
Dim BtnEdit As New Button()
BtnEdit.Text = "เลือก"
BtnEdit.Attributes.Add("runat", "server")
c.Controls.Add(BtnEdit)
r.Cells.Add(c)
AddHandler BtnEdit.Click, AddressOf BtnEdit_Click
'---- ลขข้อมูล ----
c = New HtmlTableCell()
Dim BtnDelete As New Button()
BtnDelete.Text = "เลือก"
BtnDelete.Attributes.Add("runat", "server")
c.Controls.Add(BtnDelete)
r.Cells.Add(c)
AddHandler BtnDelete.Click, AddressOf BtnDelete_Click
'---- insert row ที่ได้ ----
TableDetail.Rows.Add(r)
Next (j)
Catch ex As Exception
End Try
End Sub
End Class