TableRow Borders not showing

Having issues getting borders to show up on the TableRow objects

Page 1 of 1

2 Replies - 7700 Views - Last Post: 26 September 2009 - 03:05 PM Rate Topic: -----

#1 woodjom  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 29
  • View blog
  • Posts: 549
  • Joined: 08-May 08

TableRow Borders not showing

Post icon  Posted 25 September 2009 - 01:17 PM

I have been hitting this for several hours trying several different means of doing this through VB code.

First Attempt: various variations according to CSS styles
trow.style.add("border", "1px solid Black")


trow.style.add("border-width", "1px)
trow.style.add("border-top-style", "solid")
trow.style.add("border-color", "Black")


I shortcutted the namespaces out of the ones below:
trow.bordercolor = Black
trow.borderstyle = solid
trow.borderwidth = 1



When i do the Cells they work fine but the Row does not.


For those of you that want to see what i am doing in my code, have fun ;)
Private Sub PrintProject()
		Dim row As New TableRow
		Dim cell As New TableCell
		Dim tLabel As New Label

		tLabel.Text = Me._project
		cell.Attributes("colspan") = 5
		cell.Controls.Add(tLabel)
		row.Controls.Add(cell)
		Me._table.Controls.Add(row)
		For Each tRow As PrintTasksRow In Me._list
			row = New TableRow

'have tried putting the border CSS and border properties here
'to no avail

			row.Controls.Add(SetupCell(tRow.tid.ToString))
			row.Controls.Add(SetupCell(String.Format("{0:d}", tRow.tdue)))
			row.Controls.Add(SetupCell(tRow.tdescript.ToString))
			row.Controls.Add(SetupCell(tRow.tcomments.ToString))

			row.BorderColor = Drawing.Color.Black
			row.BorderStyle = BorderStyle.Solid
			row.BorderWidth = 1

			Me._table.Controls.Add(row)
		Next
		phPrintArea.Controls.Add(Me._table)
	End Sub



Is This A Good Question/Topic? 0
  • +

Replies To: TableRow Borders not showing

#2 tommiller85  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 15
  • Joined: 25-September 09

Re: TableRow Borders not showing

Posted 26 September 2009 - 07:56 AM

I don't think you can apply the border style to a table row. You could try something like the below or create the server side object at table level and iterate through the rows and cells.

Tom.

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="Tester._Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
	<title>Untitled Page</title>
	<style type="text/css">
		table {
			border-collapse:collapse;
		}
		table tr.border td {
			border-top: Solid 1px Black;
			border-bottom: Solid 1px Black;
		}
		.border .left {
			border-left: Solid 1px Black;
		}		
		.border .right {
			border-right: Solid 1px Black;
		}				
	</style>
</head>
<body>
	<form id="form1" runat="server">
		<table>
			<tr id="tr1" runat="server">
				<td>test</td>
				<td>test</td>
				<td>test</td>
				<td>test</td>
			</tr>
			<tr id="tr2" runat="server">
				<td>test</td>
				<td>test</td>
				<td>test</td>
				<td>test</td>
			</tr>
			<tr id="tr3" runat="server">
				<td>test</td>
				<td>test</td>
				<td>test</td>
				<td>test</td>
			</tr>
			<tr id="tr4" runat="server">
				<td>test</td>
				<td>test</td>
				<td>test</td>
				<td>test</td>
			</tr>
			<tr id="tr5" runat="server">
				<td>test</td>
				<td>test</td>
				<td>test</td>
				<td>test</td>
			</tr>												
		</table>
	</form>
</body>
</html>


using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

namespace Tester
{
	public partial class _Default : System.Web.UI.Page
	{
		protected void Page_Load(object sender, EventArgs e)
		{
			highlightCell( tr1 );
			highlightCell( tr3 );
		}

		private void highlightCell(HtmlTableRow tr)
		{
			tr.Attributes.Add("class", "border");
			tr.Cells[0].Attributes.Add("class", "left");
			tr.Cells[tr1.Cells.Count - 1].Attributes.Add("class", "right");
		}
	}
}



This post has been edited by tommiller85: 26 September 2009 - 08:05 AM

Was This Post Helpful? 0
  • +
  • -

#3 woodjom  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 29
  • View blog
  • Posts: 549
  • Joined: 08-May 08

Re: TableRow Borders not showing

Posted 26 September 2009 - 03:05 PM

Well if i cant effect a rows borders....should i dump an empty row every other row with a Horizontal, if possible?
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1