473,379 Members | 1,174 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,379 software developers and data experts.

Apply style to a dynamic table in ASP.NET page

Hi,
I have a PlaceHolder control, I need to dynamic render a HTML table to
add to this place holder. One requirement of this table is, I need style
like below
<table style="margin-left: 5;">

In my C# code, I have following code to render the table, how can I add this
style to my table?
Table t = new Table();
t.BorderWidth = 1;
t.GridLines = GridLines.Both;
t.CellPadding = 0;
t.CellSpacing = 0;
t.Width = Unit.Percentage(95);
TableRow tr = new TableRow();
TableCell tc1 = new TableCell();
tc1.Width = Unit.Percentage(30);
tc1.CssClass = "Section";
tc1.Text = "some value here";
tc1.VerticalAlign = VerticalAlign.Top;
tr.Cells.Add(tc1);
t.Rows.Add(tr);
myPlaceHolder.Controls.Add(t);
....................
--

Thanks for any suggestion!!!
WWW: http://hardywang.1accesshost.com
ICQ: 3359839
yours Hardy
Nov 18 '05 #1
2 19770
Hi,

have you tried

t.Style("margin-left")="5"

--
Teemu Keiski
MCP, Microsoft MVP (ASP.NET), AspInsiders member
ASP.NET Forum Moderator, AspAlliance Columnist
http://blogs.aspadvice.com/joteke

"Hardy Wang" <ha********@marketrend.com> wrote in message
news:ej**************@TK2MSFTNGP10.phx.gbl...
Hi,
I have a PlaceHolder control, I need to dynamic render a HTML table to
add to this place holder. One requirement of this table is, I need style
like below
<table style="margin-left: 5;">

In my C# code, I have following code to render the table, how can I add this style to my table?
Table t = new Table();
t.BorderWidth = 1;
t.GridLines = GridLines.Both;
t.CellPadding = 0;
t.CellSpacing = 0;
t.Width = Unit.Percentage(95);
TableRow tr = new TableRow();
TableCell tc1 = new TableCell();
tc1.Width = Unit.Percentage(30);
tc1.CssClass = "Section";
tc1.Text = "some value here";
tc1.VerticalAlign = VerticalAlign.Top;
tr.Cells.Add(tc1);
t.Rows.Add(tr);
myPlaceHolder.Controls.Add(t);
...................
--

Thanks for any suggestion!!!
WWW: http://hardywang.1accesshost.com
ICQ: 3359839
yours Hardy

Nov 18 '05 #2
Cool, t.Style["margin-left"]="5"; works!

Thanks!

"Teemu Keiski" <jo****@aspalliance.com> wrote in message
news:OE**************@TK2MSFTNGP10.phx.gbl...
Hi,

have you tried

t.Style("margin-left")="5"

--
Teemu Keiski
MCP, Microsoft MVP (ASP.NET), AspInsiders member
ASP.NET Forum Moderator, AspAlliance Columnist
http://blogs.aspadvice.com/joteke

"Hardy Wang" <ha********@marketrend.com> wrote in message
news:ej**************@TK2MSFTNGP10.phx.gbl...
Hi,
I have a PlaceHolder control, I need to dynamic render a HTML table to add to this place holder. One requirement of this table is, I need style
like below
<table style="margin-left: 5;">

In my C# code, I have following code to render the table, how can I add

this
style to my table?
Table t = new Table();
t.BorderWidth = 1;
t.GridLines = GridLines.Both;
t.CellPadding = 0;
t.CellSpacing = 0;
t.Width = Unit.Percentage(95);
TableRow tr = new TableRow();
TableCell tc1 = new TableCell();
tc1.Width = Unit.Percentage(30);
tc1.CssClass = "Section";
tc1.Text = "some value here";
tc1.VerticalAlign = VerticalAlign.Top;
tr.Cells.Add(tc1);
t.Rows.Add(tr);
myPlaceHolder.Controls.Add(t);
...................
--

Thanks for any suggestion!!!
WWW: http://hardywang.1accesshost.com
ICQ: 3359839
yours Hardy


Nov 18 '05 #3

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

Similar topics

7
by: Louis. | last post by:
Hi all, One can connect a CSS style to a HTML tag. I want to create a text in the style footer. I can do: <font class="footer">Here is my great footer.</font> However, the <font> tag is...
0
by: Pat Patterson | last post by:
I'm having serious issues with a page I'm developing. I just need some simple help, and was hoping someone might be able to help me out in here. I have a form, that consists of 3 pages of...
1
by: Nathan Bloomfield | last post by:
Does anyone know if there is any documentation which relates to Access2k + ? or can anyone help adjust the code? I am having trouble converting the DAO references. TITLE :INF: How to...
2
by: Hardy Wang | last post by:
Hi, I have a PlaceHolder control, I need to dynamic render a HTML table to add to this place holder. One requirement of this table is, I need style like below <table style="margin-left: 5;"> ...
2
by: jmorgret | last post by:
I am trying to apply a style contained in my Style.css sheet to a table on my content page. The master page has a link to the css. I have class="MyTable" and ID="MyTable" in the attributes of the...
3
by: Mahmoud | last post by:
When I wrote the following code to create a dynamic table with styles associated with each row, it worked in Firefox. But when this was tried in IE, the result was a table with no styles that were...
4
by: soozing | last post by:
Hi, I could use some help understanding how to get Firefox to correctly apply font and background colors to table elements. It seems to want to apply the colors from the body element to everything...
4
by: coconet | last post by:
Server is Win2K3/IIS6. I have an ASPX page with this in the <headtag: <link rel="stylesheet" type="text/css" href="<% Response.Write( "http://" + Request.ServerVariables.ToString() +...
3
by: =?Utf-8?B?U3ViYQ==?= | last post by:
I am using a asp page to dynamically create a stylesheet my asp page creates the following css element when i call the asp page my typing the url in the browser. My asp page works...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

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.