473,401 Members | 2,127 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,401 software developers and data experts.

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

May 31 '06 #1
2 1746
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" <pr**********@gmail.com> wrote in message
news:11**********************@c74g2000cwc.googlegr 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

May 31 '06 #2
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" <pr**********@gmail.com> wrote in message
news:11**********************@c74g2000cwc.googlegr 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


May 31 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Hans Merkl | last post by:
Hi, Is there a way to show the column headers of a GridView control even if there is no data? The only thing I see is the EmptyDataTemplate but I would also like to display the column headers. ...
2
by: Anonieko | last post by:
Hello ASPNET guru's, What is a clean way to go around the problem of displaying a GridView templated column where data can contain Single Quote ( ' )? I maybe too naive, but this is of course...
1
by: Eric | last post by:
I have a GridView control that I want to sort on multiple columns when I click a particular column. For example, I display Last name + ", " + First name in the first column and display id in the...
4
by: bryan | last post by:
Hi all, I am working on a .net 2.0 web app. On page load I display a gridview with a drop down list (Employees), when the user selects from the drop down list, the grid view is filled with...
3
by: William LaMartin | last post by:
I have a gridview (with no properties set) on an aspx page which I populate from an XML file with the code below. The data in the XML file looks like this <description>National Trust for...
1
by: sivagururaja | last post by:
Hi All, How can i bound the column in the gridview dynamically. When i tried to bound the column using the Code behind, it won't work. Here is my code. BoundColumn bc = new BoundColumn();...
2
by: msrahul | last post by:
Hi EveryOne I have a gridview with sorting enabled. As we all know, when sorting is enabled in a gridview, the column names in the gridview get UNDERLINED permanently. I dont want this. i want the...
0
by: Ramu528 | last post by:
Friends, I am working on excel sheet. i populated gridview with excel sheet data. the gridview has one column. have to find out the maximum length of String in that column. For example:...
5
by: DeMuy | last post by:
I have a gridview with AutoGenerateColumns=true that is presenting a challenge to me. Challenge #1 The data structure from the database server follows: Product |Qty...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.