Solved

gridview1.Columns.Count

Posted on 2009-06-30
6
397 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
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 

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

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

829 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