No display of object - redux

S

Sue

Anyone have any ideas on why the code below will show up
in a browser's sourcecode as an empty table, and is not
visible?

aspx:
<headertemplate>

<asp:Table ID="MyTable" runat="server" />

</headertemplate>

codebehind:
Class MyClass....

Protected WithEvents CaseTypeHeaderTable As
System.Web.UI.WebControls.Table = New
System.Web.UI.WebControls.Table
Protected WithEvents CaseTypeSortButton As
System.Web.UI.WebControls.Button = New
System.Web.UI.WebControls.Button
Protected WithEvents CaseTypeFilterDropDown As
System.Web.UI.WebControls.DropDownList = New
System.Web.UI.WebControls.DropDownList
Protected WithEvents CaseTypeHRow1 As
System.Web.UI.WebControls.TableRow = New
System.Web.UI.WebControls.TableRow
Protected WithEvents CaseTypeHRow2 As
System.Web.UI.WebControls.TableRow = New
System.Web.UI.WebControls.TableRow
Protected WithEvents CaseTypeHCell1 As
System.Web.UI.WebControls.TableCell = New
System.Web.UI.WebControls.TableCell
Protected WithEvents CaseTypeHCell2 As
System.Web.UI.WebControls.TableCell = New
System.Web.UI.WebControls.TableCell


private sub Page_Load.....
call setMyTable()
end sub

Private Sub setMyTable()
With Me.MySortButton
.BackColor = Color.Maroon
.ForeColor = Color.White
.ID = "MySortButton"
.Text = "Sort This Column"
.ToolTip = "Click to sort this column"
.EnableViewState = True
End With

With Me.MyFilterBox
.ID = "MyFilterBox"
.ToolTip = "Enter value on which to filter records
and press [ENTER]. To show all records clear the box and
press [ENTER]."
.EnableViewState = True
End With

With Me.MyCell1
.VerticalAlign = VerticalAlign.Bottom
.HorizontalAlign = HorizontalAlign.Center
.Controls.Add(Me.MySortButton)
End With

With Me.MyCell2
.HorizontalAlign = HorizontalAlign.Center
.VerticalAlign = VerticalAlign.Top
.Controls.Add(Me.MyFilterBox)
End With

With Me.MyRow1
.Cells.Add(Me.MyCell1)
End With

With Me.MyRow2
.Cells.Add(Me.MyCell2)
End With

With Me.MyTable
.Rows.Add(Me.MyRow1)
.Rows.Add(Me.MyRow2)
End With
End Sub
End Class

tia for any help,
Sue
 
L

Lewis Wang [MSFT]

Hi Sue,

After reviewing the description, I think the question is: You want to add
several controls to a table, and then add the table to the headertemplate
of a control (DataGrid / DataList/ Repeater). However, now the able is
showed empty in the browser. Please post here if I have any
misunderstandings.

I remembered that I have answered this issue before. Did it not work? You
may want to send me an email (remove "online") attached your simplified
source code (.vb and .aspx) then I might be able to work out what the
problem is.

Here are some suggestions:

If the table is in a header template, we need use FindControl method to get
the correct reference to it.

For example, the table is in the headertemplate of a datagrid:

Dim TestTable As Table

Private Sub DataGrid1_ItemDataBound(ByVal sender As System.Object, ByVal e
As System.Web.UI.WebControls.DataGridItemEventArgs) Handles
DataGrid1.ItemDataBound
If e.Item.ItemType = ListItemType.Header Then
Dim ctrl As Control = e.Item.FindControl("MyTable")
If Not ctrl Is Nothing Then
TestTable = CType(ctrl, Table)
End If
End If
End Sub

Then we can add rows to TestTable.

Best regards,
Lewis

This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
| Content-Class: urn:content-classes:message
| From: "Sue" <[email protected]>
| Sender: "Sue" <[email protected]>
| Subject: No display of object - redux
| Date: Wed, 6 Aug 2003 14:54:25 -0700
| Lines: 88
| Message-ID: <[email protected]>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="iso-8859-1"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
| Thread-Index: AcNcZU1xYceLz7k2TpmROkkV96DLeg==
| Newsgroups: microsoft.public.dotnet.general
| Path: cpmsftngxa06.phx.gbl
| Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.general:103772
| NNTP-Posting-Host: TK2MSFTNGXA14 10.40.1.166
| X-Tomcat-NG: microsoft.public.dotnet.general
|
| Anyone have any ideas on why the code below will show up
| in a browser's sourcecode as an empty table, and is not
| visible?
|
| aspx:
| <headertemplate>
|
| <asp:Table ID="MyTable" runat="server" />
|
| </headertemplate>
|
| codebehind:
| Class MyClass....
|
| Protected WithEvents CaseTypeHeaderTable As
| System.Web.UI.WebControls.Table = New
| System.Web.UI.WebControls.Table
| Protected WithEvents CaseTypeSortButton As
| System.Web.UI.WebControls.Button = New
| System.Web.UI.WebControls.Button
| Protected WithEvents CaseTypeFilterDropDown As
| System.Web.UI.WebControls.DropDownList = New
| System.Web.UI.WebControls.DropDownList
| Protected WithEvents CaseTypeHRow1 As
| System.Web.UI.WebControls.TableRow = New
| System.Web.UI.WebControls.TableRow
| Protected WithEvents CaseTypeHRow2 As
| System.Web.UI.WebControls.TableRow = New
| System.Web.UI.WebControls.TableRow
| Protected WithEvents CaseTypeHCell1 As
| System.Web.UI.WebControls.TableCell = New
| System.Web.UI.WebControls.TableCell
| Protected WithEvents CaseTypeHCell2 As
| System.Web.UI.WebControls.TableCell = New
| System.Web.UI.WebControls.TableCell
|
|
| private sub Page_Load.....
| call setMyTable()
| end sub
|
| Private Sub setMyTable()
| With Me.MySortButton
| .BackColor = Color.Maroon
| .ForeColor = Color.White
| .ID = "MySortButton"
| .Text = "Sort This Column"
| .ToolTip = "Click to sort this column"
| .EnableViewState = True
| End With
|
| With Me.MyFilterBox
| .ID = "MyFilterBox"
| .ToolTip = "Enter value on which to filter records
| and press [ENTER]. To show all records clear the box and
| press [ENTER]."
| .EnableViewState = True
| End With
|
| With Me.MyCell1
| .VerticalAlign = VerticalAlign.Bottom
| .HorizontalAlign = HorizontalAlign.Center
| .Controls.Add(Me.MySortButton)
| End With
|
| With Me.MyCell2
| .HorizontalAlign = HorizontalAlign.Center
| .VerticalAlign = VerticalAlign.Top
| .Controls.Add(Me.MyFilterBox)
| End With
|
| With Me.MyRow1
| .Cells.Add(Me.MyCell1)
| End With
|
| With Me.MyRow2
| .Cells.Add(Me.MyCell2)
| End With
|
| With Me.MyTable
| .Rows.Add(Me.MyRow1)
| .Rows.Add(Me.MyRow2)
| End With
| End Sub
| End Class
|
| tia for any help,
| Sue
|
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top