For Programmers: Free Programming Magazines  


Home > Archive > ASP .NET > May 2006 > how to get the column names from the gridview









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author how to get the column names from the gridview
Pradeep

2006-05-31, 8:12 am

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

Cowboy \(Gregory A. Beamer\)

2006-05-31, 8:12 am

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" <pradeep.mani@gmail.com> wrote in message
news:1149074637.157379.110940@c74g2000cwc.googlegroups.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
>



Pradeep

2006-05-31, 8:12 am

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:[color=darkred]
> 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" <pradeep.mani@gmail.com> wrote in message
> news:1149074637.157379.110940@c74g2000cwc.googlegroups.com...

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2010 codecomments.com