Solved

gridview1.Columns.Count

Posted on 2009-06-30
6
398 Views
Last Modified: 2013-12-17
I have a gridview in which the columns are automatically created. Here is my code

        GridView_FrequentAtt_Pivot.DataSource = DS;
        GridView_FrequentAtt_Pivot.DataBind();

I am trying to count the number of columns using

Response.Write(GridView_FrequentAtt_Pivot.Columns.Count);

but it always returns the number 1.

I am not sure what is going on here
0
Comment
Question by:Mr_Shaw
  • 3
  • 2
6 Comments
 
LVL 53

Assisted Solution

by:Dhaest
Dhaest earned 100 total points
ID: 24743993
Do you have returned records ?

Count records
   if(dt.Rows.count > 0)
Count columns
   if(dt.Columns.Count > 0)
0
 
LVL 39

Expert Comment

by:Pratima Pharande
ID: 24744151
check
DS.Table(0).Rows.count

0
 
LVL 39

Expert Comment

by:Pratima Pharande
ID: 24744157
check
DS.Tables(0).Rows.count
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:Mr_Shaw
ID: 24744380
yes I have 62 rows
0
 
LVL 39

Accepted Solution

by:
Pratima Pharande earned 400 total points
ID: 24744592
Count the number

DS.Tables(0).Columns.Count
0
 

Author Closing Comment

by:Mr_Shaw
ID: 31598287
thanks
0

Featured Post

Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

756 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question