dynamically generate columns

kaisersoze

Centurion
Joined
Aug 27, 2003
Messages
152
how to generate dynamically columns depening on the ouput of the datareader.

In classic asp i used to generate columns in do loop of recordset. can some help me with code
 
What kind of layout are you looking for?
You might want to take a look at the DataGrid or the DataList controls - much easier then writing the HTML yourself in a loop.
 
thanks for speed reply. It should like this:
No of columns depend on days of that month for example: 1 to 15 and 15 to end of month
for each date there may or may not be a value in the database. If there is value then should display in its appropriate date place. Date row is the header and each col should be hyperlink. when clicked on a particular hyperlink then entire information of that date should be shown in th datagrid below.
any suggestion please
 
Last edited:
Have you considerd to use something like this?

You can dynamically create colums for a datagrid on the base of some DataTable.
The boundColumn object has plenty of other options for display.
There is also the HyperLinkColumn which allows you to create hyerlink columns as well.



Protected g As DataGrid

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim dt As DataTable = getDataFromDatabase()
Dim dc As DataColumn
For Each dc In dt.Columns
Dim dbc As BoundColumn = New BoundColumn
dbc.DataField = dc.ColumnName
dbc.HeaderText = dc.ColumnName
g.Columns.Add(dbc)
Next
End Sub
 
Back
Top