473,386 Members | 1,621 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Dynamically output table results?

Can someone please recommend a good way in ASP.NET 1.1 to dynamically create
a HTML table to display some results I have in local variables?

For example, I want my HTML output to look like this:

Magazines (table header)
avg price: 4.50
total sold: 200
left in stock: 130

Revenue
today: 2000
year to date: 4500
sale running: False

Please note a couple of things:

1) each table will have the same html styles, format, and fonts. However
the properties shown for each table (such as avg price, total sold, etc) are
different, as shown in that example.

2) this data is not coming from a database or record set. Rather, I have
each value in its own local variable from the results of other business
logic. For example I have the following variables:

varAvgPrice = 4.50
varTotalSold=200
varInStock=130
varToday=2000
varYearToDate=4500
varSaleRunning=False

Now I could just hard code a table like this
<td>avg price</td> <td> <% = varAvgPrice %> </td>
but I have a few hundred results to display.

So instead I would rather create some sort of routine or use some sort of
control where I can pass it the header to use for the table, a list of the
tables properties and values to display for each table property. What are
some good ways to go about this?

Thanks,

Steve


Nov 19 '05 #1
2 1074
"Steve Franks" <pl****@postreplyhere.com> wrote in
news:No********************@comcast.com:
Can someone please recommend a good way in ASP.NET 1.1 to dynamically
create a HTML table to display some results I have in local variables?


You can use the Table, TableRow, TableCell classes to output dynamically.

Or use a DataGrid...

Or a DataList....

--
Lucas Tam (RE********@rogers.com)
Please delete "REMOVE" from the e-mail address when replying.

Newmarket Volvo Sucks! http://newmarketvolvo.tripod.com
Nov 19 '05 #2
Load your variables and values into an ArrayList for each table and
then bind to a DataGrid or DataList:

//Create this struct in your codebehind class or somewhere available to
the codebehind
public struct Variable
{
private string _name;
private string _data;

public Variable(string name,string data)
{
this._name = name;
this._data = data;
}

public string Name
{
get { return this._name; }
set { this._name = value; }
}

public string Data
{
get { return this._data; }
set { this._data = value; }
}
}

//Then you can load yours vars and bind like this...
ArrayList vars = new ArrayList();
vars.Add(new Variable("varAvgPrice","4.50"));
vars.Add(new Variable("varTotalSold","200"));
vars.Add(new Variable("varInStock","130"));

//dgTest is a DataGrid on the page
dgTest.DataSource = vars;
dgTest.DataBind();

Nov 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Dave Nouwens | last post by:
Hi All, Please accept my appologies in advance for what I expect will be a reasonably simple question. I have an html form (which is generated in php) which contains a number of rows (one row...
10
by: Randy Webb | last post by:
This page: http://www.hikksworld.com/loadJSFiles/ Is one where I was testing the ability of browsers that can/can't dynamically load a JS file with one of the three methods: 1)Changing the src...
9
by: pablo | last post by:
Dear NGers, I would like to change the alt-text with the changing of the image during a mouseover action. Can document.images.altView be changed dynamically? TIA, pablo
3
by: Kiyomi | last post by:
Hello, I create a Table1 dynamically at run time, and at the same time, I would like to create LinkButton controls, also dynamically, and insert them into each line in my Table1. I would...
5
by: Amelyan | last post by:
How can I get state of dynamically created controls (RadioButton, CheckBox, TextBox.Text) on post back when I click submit button? The only way I know is by traversing Response.Form enumberator;...
1
by: vj | last post by:
How i can populate all fileds dynamically in jsp page based on contents found in xml file? I have written jsp servlets and java class file. i transferred automatic data from jsp to servlet then to...
0
by: vijendra | last post by:
How i can populate all fileds dynamically in jsp page based on contents found in xml file?I have written jsp servlets and java class file. i transferred automatic data from jsp to servlet then to...
4
by: m.wanstall | last post by:
I have a crosstab query that compiles data for Months of the year. I have a stacked select query on top of that crosstab query that uses the latest 2 months data and exports it to a fixed length...
1
Merlin1857
by: Merlin1857 | last post by:
How to search multiple fields using ASP A major issue for me when I first started writing in VB Script was constructing the ability to search a table using multiple field input from a form and...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.