Get number of columns of a late bound GridView

Discussion in 'ASP .Net Web Controls' started by ctilly@gmail.com, Jun 27, 2006.

  1. Guest

    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.
    , Jun 27, 2006
    #1
    1. Advertising

  2. wrote:
    > 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
    Vadivel Kumar, Jun 27, 2006
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. keithb
    Replies:
    1
    Views:
    2,713
    Teemu Keiski
    Apr 8, 2006
  2. headware

    can't get data to show with bound columns

    headware, Jul 9, 2003, in forum: ASP .Net Datagrid Control
    Replies:
    4
    Views:
    190
    headware
    Jul 10, 2003
  3. Vinki

    template columns and bound columns in gridview

    Vinki, Apr 25, 2007, in forum: ASP .Net Web Controls
    Replies:
    2
    Views:
    842
    Vinki
    Apr 25, 2007
  4. Haim Katz

    Late bound sort of gridview

    Haim Katz, Aug 11, 2007, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    126
    Haim Katz
    Aug 11, 2007
  5. Nick Bennett
    Replies:
    1
    Views:
    189
    Bob Barrows [MVP]
    Jan 20, 2008
Loading...

Share This Page