iterate thru data

Results 1 to 2 of 2

Thread: iterate thru data

  1. #1
    Join Date
    Dec 1969

    Default iterate thru data

    I have info to be brought back from the database which is always one row. But it has about 125 columns.<BR><BR>I want to display this vertically down the page.<BR><BR>I dont want to have to reference any column names as there are so many.<BR><BR>Is there anyway to recurse thru this data as you would in old style asp and just show the column name from the DB next to the data from the single row.<BR><BR>cheers

  2. #2
    Join Date
    Dec 1969

    Default RE: iterate thru data

    C#-ish pseudocode:<BR><BR>DataRow myRow = &#060;do your thing to get the single row&#062;<BR><BR>foreach (DataColumn myCol in myRow.Table.Columns) {<BR>&nbsp;&nbsp;Response.Write(myCol.ColumnName); <BR>&nbsp;&nbsp;Response.Write(myRow[myCol.ColumnName]);<BR>}<BR><BR>This should work, and could be modified to work with a dataset referencing a table and column instead of explicitly declaring the datarow.<BR><BR>O&#039;Cary<BR><BR><B R>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts