So I currently work at a motor manufacturing company, in the IT department.
I recently had the pleasure of creating a web report and I decided to use a gridview. Due to the large amount of information being displayed, I decided to enable paging. All good.
However if you decide to display the total number of rows you have in the gridview, you would use gridview.rows.count....
Unfortunately this only counts the number of rows on the current page. So I did some searching and there are solutions out there, but i thought they were just a bit too confusing.
Ok, long story short, here is what I did: get the number of rows per page and multiply it by the total pages (added in the last page could have less rows) feel free to adapt this for your own use if you feel the need. (you will need to change ClockingsGrid to what ever you named your gridview)
Dim one As Integer Dim two As Integer
Clockings_Grid.DataBind() Clockings_Grid.PageIndex = 0 Clockings_Grid.DataBind() one = ((Clockings_Grid.PageCount - 1) * Clockings_Grid.Rows.Count) Clockings_Grid.PageIndex = Clockings_Grid.PageCount Clockings_Grid.DataBind() two = (Clockings_Grid.Rows.Count) Clockings_Grid.PageIndex = 0 Clockings_Grid.DataBind() Total.Text = one + two
As you may know by now, my name is Mohamed Suleman and I am a BCom IT Honours graduate and now also an MBA graduate with a passion for fast cars, table tennis, squash and body building. Be on the look out for blog posts in any of these diverse areas.