473,385 Members | 1,834 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,385 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 19772
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...
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:
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
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
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?
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
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.