kaisersoze Posted February 2, 2004 Posted February 2, 2004 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 Quote Note: I think as a programmer not as a human, so use my answer at your will
Administrators PlausiblyDamp Posted February 2, 2004 Administrators Posted February 2, 2004 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. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
kaisersoze Posted February 2, 2004 Author Posted February 2, 2004 (edited) 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 Edited February 2, 2004 by kaisersoze Quote Note: I think as a programmer not as a human, so use my answer at your will
Administrators PlausiblyDamp Posted February 2, 2004 Administrators Posted February 2, 2004 You should have a look at the DataList control - you can specify a property of RepeatColumns to say how many columns across. Also easy to data bind. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
karlhaak Posted February 2, 2004 Posted February 2, 2004 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 Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.