How do I know the number of rows in a Gridview?

  • Thread starter Thread starter COHENMARVIN
  • Start date Start date
C

COHENMARVIN

I have a gridview and I need to know the number of rows in it. I find
the Page_load and the Gridview_Load events are too early to find out
the number of rows. I can use the Gridview_databound event to check
for the number of rows. But the problem is that the user can update a
field on my form, which reduces the number of rows in the gridview,
because the gridview SELECT statement no longer finds the records when
their flag has been set to False.
For instance, if my gridview shows all people who were enrolled in a
college, and the user sets a flag that on the form that means one of
the people in the gridview is no longer enrolled, the gridview should
shrink by one row. I need to know when the gridview shrinks to zero
rows, and I don't know what gridview event I can use to tell me that.
Thanks,
Marvin
 
I have a gridview and I need to know the number of rows in it.  I find
the Page_load and the Gridview_Load events are too early to find out
the number of rows.  I can use the Gridview_databound event to check
for the number of rows.  But the problem is that the user can update a
field on my form, which reduces the number of rows in the gridview,
because the gridview SELECT statement no longer finds the records when
their flag has been set to False.
For instance, if my gridview shows all people who were enrolled in a
college, and the user sets a flag that on the form that means one of
the people in the gridview is no longer enrolled, the gridview should
shrink by one row.  I need to know when the gridview shrinks to zero
rows, and I don't know what gridview event I can use to tell me that.
Thanks,
Marvin

Interrogating the GridView control to discover the number of people
enrolled at any instant is not the best way. Use a database query so
you get the real up-to-date picture independently of the state of the
GridView.
 
Back
Top