Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/cmake/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
我正在尝试将表添加到ASP.NET中已创建表的单元格中_Asp.net_Webforms - Fatal编程技术网

我正在尝试将表添加到ASP.NET中已创建表的单元格中

我正在尝试将表添加到ASP.NET中已创建表的单元格中,asp.net,webforms,Asp.net,Webforms,我正在使用asp.net代码创建一个表。此表用于布局。请不要告诉我这不是正确的方法。我被另一个程序员强迫去做。然后,我使用例程创建一个表,分配datatable值,并将该表添加到我先前创建的一个单元格中。当我使用obj.Controls.Add(tbl)添加表格时。当我运行它时,它告诉我tbl可能是空的,我知道它不是空的。有什么想法吗 Public Sub CreateTable() Dim tbl As Table Dim tbl1 As Table Dim tr A

我正在使用asp.net代码创建一个表。此表用于布局。请不要告诉我这不是正确的方法。我被另一个程序员强迫去做。然后,我使用例程创建一个表,分配datatable值,并将该表添加到我先前创建的一个单元格中。当我使用
obj.Controls.Add(tbl)
添加表格时。当我运行它时,它告诉我
tbl
可能是空的,我知道它不是空的。有什么想法吗

 Public Sub CreateTable()
    Dim tbl As Table
    Dim tbl1 As Table
    Dim tr As TableRow
    Dim tc As TableCell
    Dim objVolume As New DBAdult.VOLUME
    Dim objDeleteAFile As New DBAdult.DeleteAFile
    Dim maxSeqNum As Int16
    Dim maxLocSeqNum As Int16
    Dim tblCounter As Int16
    Dim rowCounter As Int16
    Dim cellCounter As Int16
    Dim containerTable As Table
    Dim dt As DataTable
    Dim dr As DataRow
    Dim cc As TableCell
    Dim dtTable As Table
    Dim numCells As Long
    Dim VolLocHistInfo1 As String
    Dim VolLocHistInfo2 As String
    Dim VolLocHistInfo3 As String
    Dim VolLocHistInfo4 As String
    Dim insertCell As TableCell
    Dim obj As TableCell

    tbl = VolLocHistInfoContainer
    maxSeqNum = objVolume.GetMaxBarcodeNum(fileID, 8)
    maxLocSeqNum = objVolume.GetMaxVolLocSeqNum(fileID)
    dt = objDeleteAFile.dbAdultVolLocHist(fileID)
    Dim x As Integer
    x = dt.Rows.Count
    For Each dr In dt.Rows
        tbl = New Table
        tr = New TableRow
        tc = New TableCell
        tc.Attributes.Add("runat", "server")
        tc.Style("Border-Color") = "#000000"
        tc.Style("Border-Style") = "Solid"
        tc.Style("Border-Width") = "1pt"
        tc.Style("width") = "65%"
        tc.Style("background-color") = "#E9E9E9"
        tc.Text = "Volume Barcode Number"
        tr.Cells.Add(tc)
        tc = New TableCell
        tc.Attributes.Add("runat", "server")
        tc.Style("Border-Color") = "#000000"
        tc.Style("Border-Style") = "Solid"
        tc.Style("Border-Width") = "1pt"
        tc.Style("width") = "35%"
        tc.Text = dr(1).ToString()
        tr.Cells.Add(tc)
        tbl.Rows.Add(tr)
        '******************************************************************************************

        tr = New TableRow
        tc = New TableCell
        tc.Attributes.Add("runat", "server")
        tc.Style("Border-Color") = "#000000"
        tc.Style("Border-Style") = "Solid"
        tc.Style("Border-Width") = "1pt"
        tc.Style("width") = "65%"
        tc.Style("background-color") = "#E9E9E9"
        tc.Text = "Archive  Location"
        tr.Cells.Add(tc)
        tc = New TableCell
        tc.Attributes.Add("runat", "server")
        tc.Style("Border-Color") = "#000000"
        tc.Style("Border-Style") = "Solid"
        tc.Style("Border-Width") = "1pt"
        tc.Style("width") = "35%"
        tc.Text = dr(2).ToString()
        tr.Cells.Add(tc)
        tbl.Rows.Add(tr)
        '******************************************************************************************

        tr = New TableRow
        tc = New TableCell
        tc.Attributes.Add("runat", "server")
        tc.Style("Border-Color") = "#000000"
        tc.Style("Border-Style") = "Solid"
        tc.Style("Border-Width") = "1pt"
        tc.Style("width") = "65%"
        tc.Style("background-color") = "#E9E9E9"
        tc.Text = "Storage Type"
        tr.Cells.Add(tc)
        tc = New TableCell
        tc.Attributes.Add("runat", "server")
        tc.Style("Border-Color") = "#000000"
        tc.Style("Border-Style") = "Solid"
        tc.Style("Border-Width") = "1pt"
        tc.Style("width") = "35%"
        tc.Text = dr(3).ToString()
        tr.Cells.Add(tc)
        tbl.Rows.Add(tr)
        '******************************************************************************************

        tr = New TableRow
        tc = New TableCell
        tc.Attributes.Add("runat", "server")
        tc.Style("Border-Color") = "#000000"
        tc.Style("Border-Style") = "Solid"
        tc.Style("Border-Width") = "1pt"
        tc.Style("width") = "65%"
        tc.Style("background-color") = "#E9E9E9"
        tc.Text = "Note"
        tr.Cells.Add(tc)
        tc = New TableCell
        tc.Attributes.Add("runat", "server")
        tc.Style("Border-Color") = "#000000"
        tc.Style("Border-Style") = "Solid"
        tc.Style("Border-Width") = "1pt"
        tc.Text = dr(4).ToString()
        tc.Style("width") = "35%"
        tr.Cells.Add(tc)
        tbl.Rows.Add(tr)
        '******************************************************************************************

        obj = Page.FindControl("AdultVolLocHistContainer")
        obj.Controls.Add(tbl)
    Next
END SUB

你能解释一下这是什么吗:tbl=VolLocHistInfoContainer?如果您可以添加实际的错误文本,也会很有用。请编辑您的问题并添加准确的错误消息。另外,请验证这一行:
obj=Page.FindControl(“AdultVolLocHistContainer”)
正在查找该控件。此外,您似乎在说您比.NET更了解什么是空的,什么不是空的。我不这么认为。相反,我建议您假设.NET没有欺骗您,然后继续问自己.NET告诉您真相需要什么条件。为了使obj=Page.FindControl(“AdultVolLocHistContainer”)起作用,AdultVolLocHistContainer必须是顶级元素。您可能会考虑使用递归方法: