DarkW1nter
DarkW1nter

Reputation: 2861

Get current gridview.rows.count

I have a gridview where I set the datasource when the user click a button on the form. Im trying to get the rowcount of the gridview using the same button_click event, but its returning the rowcount previous to the datasource being set, ie 0. Im using

strCount = gvReturned.Rows.Count.Tostring();

Any hints appreciated.

thanks

T

Upvotes: 0

Views: 5654

Answers (2)

Trevor Pilley
Trevor Pilley

Reputation: 16423

Try listening to the DataSourceChanged event

Upvotes: 1

Blachshma
Blachshma

Reputation: 17405

Try calling

   gvReturned.DataBind() 

after setting the source but before requesting the count..

Upvotes: 0

Related Questions