![]() |
|
|
|||||||
![]() |
ASP Net - how to get the column names from the gridview |
|
|
Thread Tools | Search this Thread |
|
|
#1 |
|
Posts: n/a
|
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 |
|
|
|
#2 |
|
Posts: n/a
|
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 > |
|
|
|
#3 |
|
Posts: n/a
|
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 > > |
|
![]() |
| Thread Tools | Search this Thread |
|
|
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 |