Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > how to get the column names from the gridview

Reply
Thread Tools

how to get the column names from the gridview

 
 
Pradeep
Guest
Posts: n/a
 
      05-31-2006
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
 
 
 
 
Cowboy \(Gregory A. Beamer\)
Guest
Posts: n/a
 
      05-31-2006
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) 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
 
 
 
 
Pradeep
Guest
Posts: n/a
 
      05-31-2006
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" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed) 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

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

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
gridview column values to another page via gridview hyperlink column Keith G Hicks ASP .Net 3 02-18-2008 06:17 AM
1 Gridview. Dropdown A is column from database, Dropdown B is column from database, Data in A and B must be from same row. anonymoushamster@gmail.com ASP .Net 2 11-07-2007 12:40 PM
GridView - Setting the text of the 'select' column to the value of another column Greg Smith ASP .Net 0 04-12-2007 03:11 PM
How to hide a GridView column when the column's Visible property does not support databinding? Keithb ASP .Net 2 10-27-2006 05:02 AM



Advertisments