Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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

Note: I think as a programmer not as a human, so use my answer at your will
Posted (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 by kaisersoze
Note: I think as a programmer not as a human, so use my answer at your will
Posted

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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...