Get number of columns of a late bound GridView

C

ctilly

If I have a GridView that I don't bind until run time like so...

GridView1.DataSource = someTable;
GridView1.DataBind();

Is it possible for me to use the Count property? When I attempt
something like this..

GridView1.Columns.Count I always get a 0. I can't figure it out.

Any thoughts?

Regards.
 
V

Vadivel Kumar

If I have a GridView that I don't bind until run time like so...

GridView1.DataSource = someTable;
GridView1.DataBind();

Is it possible for me to use the Count property? When I attempt
something like this..

GridView1.Columns.Count I always get a 0. I can't figure it out.

Any thoughts?

Regards.

Its only matters that in which event you're binding the data and calling
the Count property.

GridView control will assign the data source once after the RowDataBound
event.

Check for this and call the Count property in appropriate place.

If you're problem is not solved, please post some of your code here.

-
Vadivel Kumar
http://vadivelk.net
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top