Results 1 to 4 of 4

Thread: Getting Column (field) headers of Table

  1. #1

    Thread Starter
    Addicted Member diban's Avatar
    Join Date
    Aug 2002
    Location
    IN
    Posts
    152

    Getting Column (field) headers of Table

    Hi

    How can I get the names of the fields/columns of a table using DataReader?

    I want to display the column names and their value in html but just can't find a way to get the simple task done.

    I'm new to ASP.NET and I'm working on VB code for ASP.NET not c#...

    Thanks

  2. #2
    New Member
    Join Date
    Jul 2004
    Location
    Lansing, MI
    Posts
    11

    Re: Getting Column (field) headers of Table

    You'll want to use a Datagrid to accomplish this as, with .NET, the datagrid is king when it comes to automating the HTML table display process (trust me when I say that you'll love this aspect of .NET) The asp.net data grid will do exactly what you want (grab column name and display data in tabular format) at its most basic but it can really do some advanced functions (like multi-column sorting or editing) with relative ease. The best place to start with this control is the 4guysfrom rolla indepth look at the datagrid - the aticle spans 18 seperate articles in all ranging from beginning databinding (your question) to advanced concepts like sorting, etc... and they provide great source code and examples as well. Heres the link: datagrid link

    hth!
    Kev

  3. #3

    Thread Starter
    Addicted Member diban's Avatar
    Join Date
    Aug 2002
    Location
    IN
    Posts
    152

    Re: Getting Column (field) headers of Table

    Hi

    Thanks for your reply. What I'm trying to do is get the format in a String variable and send the string as an email body to the administrator.

    What you suggested is great. I tried it too and for a programmer with a VB background, this was quite easy to understand too. However, can I achieve my goal with a datagrid? If so, please let me know.

    Thanks

  4. #4
    Fanatic Member -TPM-'s Avatar
    Join Date
    Jul 2005
    Posts
    850

    Re: Getting Column (field) headers of Table

    You can get the names straight from the datatable like this:
    datatable.Columns(ColumnIndex).ColumnName()
    TPM

    Add yourself to the VBForums Frappr Map!!

Posting Permissions

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



Click Here to Expand Forum to Full Width