Go Back   Velocity Reviews > Newsgroups > ASP Net
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read


Reply

ASP Net - how to get the column names from the gridview

 
Thread Tools Search this Thread
Old 05-31-2006, 11:23 AM   #1
Pradeep
 
Posts: n/a
Default how to get the column names from the gridview

hi,
im having a very peculiar problem. I populate the gridview based on the
result of a query, and the gridview shows the rows that are returned by
the query.
now if i give gridview1.rows.count i get exactly the no of rows in the
gridview but when i give gridview1.columns.count i always get it as 0
despite columns being present in the gridview. Does anyone know y this
happens ?
Also, i want to get the column names say like age, name, address etc
from the gridview..how can i do this ?? will
gridview1.columns[i].headertext do the job?? (i being an index
variable)
bye
pradeep

  Reply With Quote
Old 05-31-2006, 12:06 PM   #2
Cowboy \(Gregory A. Beamer\)
 
Posts: n/a
Default Re: how to get the column names from the gridview

In a DataSet, you have access to rows and columns in the manner you
prescribe. When you paint on the page, the cells/columns (TDs) are inside
the rows (TRs), as items are ultimately "painted:" as HTML tables. Try
looking at the cell collection of the header row.

--
Gregory A. Beamer

*************************************************
Think Outside the Box!
*************************************************
"Pradeep" <> wrote in message
news: oups.com...
> hi,
> im having a very peculiar problem. I populate the gridview based on the
> result of a query, and the gridview shows the rows that are returned by
> the query.
> now if i give gridview1.rows.count i get exactly the no of rows in the
> gridview but when i give gridview1.columns.count i always get it as 0
> despite columns being present in the gridview. Does anyone know y this
> happens ?
> Also, i want to get the column names say like age, name, address etc
> from the gridview..how can i do this ?? will
> gridview1.columns[i].headertext do the job?? (i being an index
> variable)
> bye
> pradeep
>



  Reply With Quote
Old 05-31-2006, 12:26 PM   #3
Pradeep
 
Posts: n/a
Default Re: how to get the column names from the gridview

Hello Cowboy,
Thanks for giving the hint...
Gridview1.headerrow.cells[i].text did the job
Thank u very much...i was pullin my hair from the morning not knowing
how to do this..
thanks again
Bye
Pradeep



Cowboy (Gregory A. Beamer) wrote:
> In a DataSet, you have access to rows and columns in the manner you
> prescribe. When you paint on the page, the cells/columns (TDs) are inside
> the rows (TRs), as items are ultimately "painted:" as HTML tables. Try
> looking at the cell collection of the header row.
>
> --
> Gregory A. Beamer
>
> *************************************************
> Think Outside the Box!
> *************************************************
> "Pradeep" <> wrote in message
> news: oups.com...
> > hi,
> > im having a very peculiar problem. I populate the gridview based on the
> > result of a query, and the gridview shows the rows that are returned by
> > the query.
> > now if i give gridview1.rows.count i get exactly the no of rows in the
> > gridview but when i give gridview1.columns.count i always get it as 0
> > despite columns being present in the gridview. Does anyone know y this
> > happens ?
> > Also, i want to get the column names say like age, name, address etc
> > from the gridview..how can i do this ?? will
> > gridview1.columns[i].headertext do the job?? (i being an index
> > variable)
> > bye
> > pradeep
> >


  Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Gridview row information disappearing after selectedIndexChanged Ry99 General Help Related Topics 0 07-13-2009 02:35 PM
The GridView 'GridView1' fired event Sorting which wasn't handled. rajendrasedhain Software 0 07-08-2008 07:52 PM
Checkbox values problem in gridview thanigaimani.thirumalai Software 0 11-09-2007 04:12 AM
Counting In Binary Raymond A+ Certification 13 03-07-2004 06:28 PM
I LOVE FULLSCREEN Lookingglass DVD Video 139 01-06-2004 01:13 AM




SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47