Something like this...
**************************
<%@ Page Language="vb" AutoEventWireup="false" Codebehind="WebForm5.aspx.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>WebForm5</title>
<meta name="GENERATOR" content="Microsoft Visual Studio.NET 7.0">
<meta name="CODE_LANGUAGE" content="Visual Basic 7.0">
<meta name=vs_defaultClientScrip
<meta name=vs_targetSchema content="http://schemas.mi
<style>
.Category {
background-color: #CECECE;
}
.SubCategoryHidden {
visibilitiy: hidden;
display: none;
}
.SubCategoryVisible {
visibilitiy: visible;
display: block;
}
</style>
<script language="javascript">
function ShowSubCategories(oThis)
{
var CurrentCategoryIndex = oThis.rowIndex;
var Rows = oThis.parentNode.rows;
for (i = 1 ; i < Rows.length ; i++)
{
Rows[i].className = Rows[i].className.replace(
}
for (i = oThis.rowIndex + 1 ; i < Rows.length ; i++)
{
if (Rows[i].className == "Category")
{
break;
}
else
{
Rows[i].className = "SubCategoryVisible";
}
}
}
</script>
</head>
<body OnLoad="ShowSubCategories(
<form id="MyForm" method="post" runat="server">
<asp:DataGrid ID="MyDataGrid" Runat="server" CellPadding="0" CellSpacing="0" BorderWidth="1"></asp:Data
</form>
</body>
</html>
**************************
Public Class WebForm5
Inherits System.Web.UI.Page
Protected WithEvents MyDataGrid As System.Web.UI.WebControls.
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
<System.Diagnostics.Debugg
End Sub
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub
#End Region
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If (Not IsPostBack()) Then
Call BindData()
End If
End Sub
Sub BindData()
Dim MyDataTable As New DataTable()
MyDataTable.Columns.Add("C
MyDataTable.Columns.Add("C
MyDataTable.Columns.Add("S
MyDataTable.Columns.Add("S
Dim MyDataRow As DataRow
Dim i, j As Int32
For i = 1 To 5
MyDataRow = MyDataTable.NewRow()
MyDataRow.Item("CategoryID
MyDataRow.Item("CategoryNa
MyDataRow.Item("SubCategor
MyDataRow.Item("SubCategor
Call MyDataTable.Rows.Add(MyDat
For j = 1 To 3
MyDataRow = MyDataTable.NewRow()
MyDataRow.Item("CategoryID
MyDataRow.Item("CategoryNa
MyDataRow.Item("SubCategor
MyDataRow.Item("SubCategor
Call MyDataTable.Rows.Add(MyDat
Next
Next
MyDataGrid.DataSource = MyDataTable
Call MyDataGrid.DataBind()
End Sub
Private Sub MyDataGrid_ItemDataBound(B
If ((e.Item.ItemType = ListItemType.Item) Or (e.Item.ItemType = ListItemType.AlternatingIt
If (e.Item.DataItem("SubCateg
e.Item.CssClass = "SubCategoryHidden"
Else
e.Item.CssClass = "Category"
e.Item.Attributes.Add("onc
End If
End If
End Sub
End Class
Main Topics
Browse All Topics





by: HeadspacePosted on 2005-06-18 at 20:53:59ID: 14250569
Rather than using the asp:table control, can you use an html table instead? You can build it in the codebehind using the HtmlGenericControl and LiteralControl classes. once you've built the table, you can either place it inside of another control (e.g. a predefined Panel control) or simply add it directly to the page.