Solved

Display ASP.Net Tables (markup) from VB.Net (code behind) through ASP Literal in PassThrough

Posted on 2012-12-26
2
344 Views
Last Modified: 2013-01-09
I would like to dynamically create ASP tables using VB to dynamically populate the data and provide unique IDs and then assign it to a Literal in Passthrough mode.

How can I go about qualifying my code with quotation marks around ASP parameters and having VB.Net accept/concatinate my string properly?  I know the vb is being triggered because I also have a label change.

Sample of my code:
htmlText = "<asp:TableRow ID=""TR1C" & intC.ToString() & """>"

CraneTables.Text = htmlText.ToString()

(In the ASP page)
<asp:Literal ID="CraneTables" Mode="PassThrough" EnableViewState="false" runat="server"></asp:Literal>

Open in new window


I'm not an expert in ASP, so if there is a better way for me to do this can you please provide some examples.  I am trying to keep it all in the code behind because I will also be pulling in data from multiple MS SQL queries and have Create/Update/Delete tied into it.

Thank you.
0
Comment
Question by:quistlogic
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 75

Accepted Solution

by:
käµfm³d   👽 earned 250 total points
ID: 38722615
This:

htmlText = "<asp:TableRow ID=""TR1C" & intC.ToString() & """>"

Open in new window


...is not going to work. You cannot create server-side controls via a string. Such controls need to be present in the markup at the time the view engine runs. Aside from that, your approach seems complicated. Why not just create a table in your code-behind?

e.g.

Code-behind
Dim t As New Table()
Dim r As New TableRow()
Dim c As New TableCell()

c.Text = "Hello World!"
r.Cells.Add(c)
t.Rows.Add(r)
t.ID = "TR1C" + i.ToString()
Me.placeholder1.Controls.Add(t)

Open in new window


Markup
<asp:Placehodler ID="placeholder1" runat="server"></asp:Placeholder>

Open in new window

0
 
LVL 2

Author Closing Comment

by:quistlogic
ID: 38761132
This is a great way to display data and control it.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Browsers only know CSS so your awesome SASS code needs to be translated into normal CSS. Here I'll try to explain what you should aim for in order to take full advantage of SASS.
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

717 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question