Solved

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

Posted on 2012-12-26
2
335 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
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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

What is Node.js? Node.js is a server side scripting language much like PHP or ASP but is used to implement the complete package of HTTP webserver and application framework. The difference is that Node.js’s execution engine is asynchronous and event…
Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

776 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