Out
Out

Reputation: 675

How to get count of visible rows in Grid View?

I Have GridView with both visible and invisible rows in it,

But i just want count of only visible Rows in that grid

i have tried this

int rowCount = gv_SPAvailable.Rows.Count(row => row.IsVisible); 

But i could not get, is there any other way, any one please help

Upvotes: 0

Views: 9140

Answers (2)

Out
Out

Reputation: 675

Also these code is working fine

     int numVisible = 0; 
        foreach(GridViewRow row in gv_SPAvailable.Rows) 
        { 
            if(row.Visible == true) 
            { 
                numVisible += 1; 
            } 
        }

Upvotes: 1

Alex Filipovici
Alex Filipovici

Reputation: 32561

Try this:

int rowCount = gv_SPAvailable.Rows.GetRowCount(DataGridViewElementStates.Visible);

Upvotes: 5

Related Questions