Robert,
Here is an example of adding a checkbox into a prexisting template column in
a datagrid. You can also dynamically add columns to the datagrid prior to
adding the checkbox controls.
Dim Item As DataGridItem
Header1.Title = "Site User Admin"
Try
With dgUsers
.DataSource = Site.Users(CStr(Session.Item("SiteID")))
.DataBind()
'Add the Checkbox to the grid
For Each Item In dgUsers.Items
Dim Chkbox As New CheckBox()
'Check the box if the User has level 2 access or above
If CInt(Item.Cells(4).Text) > 1 Then
Chkbox.Checked = True
Else
Chkbox.Checked = False
End If
Item.Cells(1).Controls.Add(Chkbox)
Next
End With
Catch ex As Exception
ExceptionManager.Publish(ex)
Response.Redirect("Error.aspx", False)
End Try
--Gene Dershewitz
-----Original Message-----
From: Robert Sindall [mailto:rsindall@z...]
Sent: Thursday, October 24, 2002 10:28 AM
To: ASPX_Professional
Subject: [aspx_professional] Data Grid - Dynamic Columns
Hi
I'm trying to build a datagrid which has a dynamic number of columns...
Lets say its a user table. users going down and roles across.
as i add new roles i need to add them to the end of the datagrid
dynamically?
Each column would contain a check box.
Is there a good example of this anywhere?
Thanks
Robert
---
ASP.NET 1.0 Namespace Reference with C#
http://www.wrox.com/acon11.asp?ISBN=1861007442
ASP.NET 1.0 Namespace Reference with VB.NET
http://www.wrox.com/acon11.asp?ISBN=1861007450
These books are a complete reference to the ASP.NET namespaces
for developers who are already familiar with using ASP.NET.
There is no trivial introductory material or useless .NET
hype and the presentation of the namespaces, in an easy-to use
alphabetical order ensures a user-friendly reference format.
We provide in-depth coverage of all the major ASP.NET classes,
giving you those real-world tips that the documentation doesn't
offer, and demonstrating complex techniques with simple
examples.
---