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

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
 
S

Stan

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.
 

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,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top