|
-
Sep 12th, 2005, 02:23 PM
#1
Thread Starter
Addicted Member
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
-
Sep 12th, 2005, 04:23 PM
#2
New Member
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
-
Sep 12th, 2005, 11:06 PM
#3
Thread Starter
Addicted Member
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
-
Sep 13th, 2005, 09:40 AM
#4
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|