Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > Dynamically writing a <BR> in a panel or placeholder

Reply
Thread Tools

Dynamically writing a <BR> in a panel or placeholder

 
 
CoreyMas
Guest
Posts: n/a
 
      02-25-2005
Hello everyone,

I am in a bit of a dilema trying to write an HTML <br> tag into a panel or
placeholder.

Here is the situation

I have 4 tables that represent 4 levels of data (level4 is linked to a
level3 etc) all the way up to a level 1

Example

Level1
Level2a
Level2b
Level3a
Level3B
Level4a
Level4b
Level2c


I am using a datalist to contain these 4 levels, but I want to recreate a
tree like structure so that the user can easily see what level2's are in a
level1 as well as select a particular level to see its details.

The link buttons work fine but I am unable to get the levels to look right.
So I looked at trying to add a BR tag at the end of each level but it does
not seem to be working.

This is the result that I am getting:

Level1Level2aLevel........

When I look at the View Source on the web page the <br> tags are NOT there.

What am I doing wrong?

I thought about trying to use HtmlTextWriter, but I have NO idea how that
works and the examples in VS are not very explicit.

Any help would be much appreciated... I am even open to other ways to create
this tree like structure.

BTW - I am using VS 2003.

Here is the code that I have created so far for my datalist itemdatabound:

Private Sub dlstMaster_ItemDataBound(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.DataListItemEventArgs) Handles
dlstMaster.ItemDataBound
Dim dv As DataRowView = e.Item.DataItem
Dim spacer As New LiteralControl("<br>")
Dim level1linkbutton As New LinkButton
Dim level1panel As PlaceHolder = e.Item.FindControl("Level1Panel")
level1linkbutton.Text = dv("Level1Name")
level1linkbutton.CommandArgument = dv("Level1Id").ToString
level1linkbutton.CommandName = "Level1Click"
level1panel.Controls.Add(level1linkbutton)
level1panel.Controls.Add(spacer)
Dim ds As New DataSet
ds = Session("ds")
If Not dv Is Nothing Then
Dim level2dv As DataView
level2dv = dv.CreateChildView("level2")
Dim row As DataRowView
For Each row In level2dv
Dim level2linkbutton As New LinkButton
level2linkbutton.Text = row("Level2Name")
level2linkbutton.CommandArgument = row("Level2Id").ToString
level2linkbutton.CommandName = "Level2Click"

level1panel.Controls.Add(level2linkbutton)
level1panel.Controls.Add(spacer)
' Now loop through the level 3 details
Dim level3dv As DataView
level3dv = New DataView(ds.Tables("AllLevel3"), "Level2Id =
'" & row("Level2Id").ToString & "'", "Level3Name",
DataViewRowState.CurrentRows)
Dim level3row As DataRowView
For Each level3row In level3dv
Dim level3linkbutton As New LinkButton
level3linkbutton.Text = level3row("Level3Name")
level3linkbutton.CommandArgument =
level3row("Level3Id").ToString
level3linkbutton.CommandName = "Level3Click"
level1panel.Controls.Add(level3linkbutton)
level1panel.Controls.Add(spacer)
' now get the level 4's
Dim level4dv As DataView
level4dv = New DataView(ds.Tables("AllLevel4"),
"Level3Id = '" & level3row("Level3Id").ToString & "'", "Level4Name",
DataViewRowState.CurrentRows)
Dim level4row As DataRowView
For Each level4row In level4dv
Dim level4linkbutton As New LinkButton
level4linkbutton.Text = level4row("Level4Name")
level4linkbutton.CommandArgument =
level4row("Level4Id").ToString
level4linkbutton.CommandName = "Level4Click"
level1panel.Controls.Add(level4linkbutton)
level1panel.Controls.Add(spacer)
Next
Next
Next
End If
End Sub

The problem is that when I add the spacer control (a literal control with
the BR in it) it is not added into the placeholder. I have tried to use a
panel, with the same effect
 
Reply With Quote
 
 
 
 
MasterGaurav
Guest
Posts: n/a
 
      02-25-2005
You must have a unique instance of LiteralControl everytime.

Controls.Add(new LiteralControl("<br/>"))


--
Cheers,
Gaurav Vaish
http://www.mastergaurav.org
http://mastergaurav.blogspot.com
--------------------------------

 
Reply With Quote
 
 
 
 
MasterGaurav
Guest
Posts: n/a
 
      02-25-2005
You must have a unique instance of LiteralControl everytime.

Controls.Add(new LiteralControl("<br/>"))


--
Cheers,
Gaurav Vaish
http://www.mastergaurav.org
http://mastergaurav.blogspot.com
--------------------------------

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Placeholder or Panel Ralph Krausse ASP .Net 1 10-07-2004 03:52 PM
Build control in a placeholder or like a placeholder nail ASP .Net Building Controls 0 09-10-2004 07:57 PM
HOWTO: Remove <span> tag from Panel and PlaceHolder WebControls? Don Wash ASP .Net 2 09-07-2004 12:22 AM
panel / placeholder problem TJS ASP .Net 1 09-02-2004 04:10 PM
Panel PlaceHolder Div Difference? bdwise ASP .Net 2 02-24-2004 01:48 PM



Advertisments