New - Conditional Formmatting

Hello, I am very new to ASP.NET.

I am trying to display data diffently depending on its “subparent” in an SQL Database. For example:


  • Complete drywall
  • Patch work
  • Mud and taping


  • Complete room painting
  • Touch up painting
  • Exterior Painting

The only thing I have right now is some code that creates a new Data Table depending on the parentID but I cannot get it to display the way I want. The parent item h2 and the subitems with a bullet point. Please help. Thanks.

What is your database structure with sample data and what are you trying to show?

Research: Nested ListView’s. It will show you what you need. The first listview will return an H2, after that, the nested ListView will add the LI’s under the H2. Easier then you think, and their are pleanty of resources on the net for this technique.

Good Luck.

Yes, okay I am using a Sql Server Database here is the sample data.

Table Name: SiteContent

TextID Text Level ParentID
1 Residential Construciton 0 null
2 Kitchen and Bathroom 1 1
3 Commercial Contractor 0 null
4 New Commercial Work 1 3
5 Other Commerical Work 1 3

And right now I have them displaying as a table (with the help of some online tutorial)… here is the code…

Table Table1 = (Table)e.Item.FindControl("Table1");
Table1.Width = Unit.Percentage(100);
Table1.BorderStyle = BorderStyle.None;
Table1.BorderWidth = Unit.Pixel(1);
Table1.CellPadding = 0;
Table1.CellSpacing = 0;

TableRow tblRow = new TableRow();

TableCell tblEmptyCell = new TableCell();
tblEmptyCell.Controls.Add(new LiteralControl(String.Empty));
tblEmptyCell.Width =
                Unit.Percentage(30 * Convert.ToInt32(((DataRowView)(e.Item.DataItem))["Level"].ToString()));

TableCell tblCell = new TableCell();
tblCell.Controls.Add(new LiteralControl(((DataRowView)(e.Item.DataItem))["Text"].ToString()));
tblCell.HorizontalAlign = HorizontalAlign.Left;

It displays like a table but I want it to look like this…

Residential Constractor

  • Kitchen and Bathroom

Commerical Constractor

  • New Commerical Work
  • Other Commerical Work

Hope this helps… I just don’t know how to change the Text and add the Bullet Points to the code above or to the ASPX file…