Home All Groups Group Topic Archive Search About

Get number of columns of a late bound GridView

Author
27 Jun 2006 1:18 AM
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.

Author
27 Jun 2006 12:53 PM
Vadivel Kumar
cti***@gmail.com wrote:
Show quoteHide quote
> 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

Bookmark and Share