Search code examples
c#htmlstylesheet

Giving Borders to the dynamically added HTML table


I have a HTML table added dynamically in my Code behind.

I am able to give the entire table a border.

How can I do this for each row? I want to add a border under each row.

How can I add a hyperlink to cells at runtime?

What I have tried is

tdr.Width = "100px";
tdr.Attributes.Add("class", "float-left");

row = new HtmlTableRow(); 
cell = new HtmlTableCell();
cell.InnerText = doc;
row.Cells.Add(cell);
tdr.Rows.Add(row);

row = new HtmlTableRow(); 
cell = new HtmlTableCell();
cell.InnerText = "No Timming";
row.Cells.Add(cell);
tdr.Rows.Add(row);

row = new HtmlTableRow(); 
cell = new HtmlTableCell();
cell.InnerText = weekday[i];
row.Cells.Add(cell);
tdr.Rows.Add(row);

And my CSS:

<style type="text/css">
    .float-left
    {
        float:left;
        border-style:solid;
        border-width:2px;
        border-color:Black;
    }
</style>

Solution

  • you need to add a css on your TR (row)

    or an inline border like this:

     row.Attributes.Add("border-bottom", "solid red 1px");