做点补充说明:设计理念是 页面上放了一个table服务器控件,还有一个按钮,当我一按下按钮,页面会回发处理后,并在table中生成一个tableRow,tableRow中有一个动态生成的linkbut控件,这个控件有个事件是myLBut_click,但我一点这个控件,怎么页面上什么都没了。
Protected Sub butFind_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles butFind.Click
Dim FindFileName As New FindFile
Dim strFindPath As String = "F:\Visual Studio 2008\WebSites\FileSys\Files\SurveillanceCenterFiles"
Dim strFindName As String = TxtFindFileName.Text
Dim myFileSystemInfo As FileSystemInfo
myFileSystemInfo = FindFileName.FindFile(strFindName, strFindPath)
If myFileSystemInfo IsNot Nothing Then
AddTableHead()
Dim tRow As New TableRow
Dim tCells As TableCell()
tCells = New TableCell(4) {New TableCell, New TableCell, New TableCell, New TableCell, New TableCell}
tCells(0).Text = myFileSystemInfo.Name
If myFileSystemInfo.Attributes = FileAttributes.Directory Then
tCells(1).Text = "目录"
Else
tCells(1).Text = "文件"
End If
Dim myLBut As New LinkButton
myLBut.Text = "操作类型"
myLBut.ID = "myLBut"
AddHandler myLBut.Click, AddressOf myLBut_click '为什么按下LinkButton后,页面什么都没有了。如果说一定要将代码放在page_load事件中还是算了,有没有其他方法解决
tCells(2).Controls.Add(myLBut)
tCells(3).Text = "上传时间"
tCells(4).Text = "上传人"
tRow.Cells.AddRange(tCells)
TableFilesBrowe.Rows.Add(tRow)
End If
End Sub
Sub myLBut_click()
AddTableHead()
Dim tRow As New TableRow
Dim tCells As TableCell()
tCells = New TableCell(4) {New TableCell, New TableCell, New TableCell, New TableCell, New TableCell}
tCells(0).Text = "fjdk"
tCells(1).Text = "fjdk"
tCells(2).Text = "fjdk"
tCells(3).Text = "fjdk"
tCells(4).Text = "fjdk"
tRow.Cells.AddRange(tCells)
TableFilesBrowe.Rows.Add(tRow)
End Sub