I have a
You can convert the GridView's DataSource to DataTable or DataView and then count the rows.
DataTable dt = (DataTable) gridView.DataSource; int count = dt.Rows.Count;
But this will be available only at the time of binding, not across the postback.
To get the row count on post back, you can store the
DataTable or its row count in session before binding it to the GridView.
DataTable dt = GetDataSourceTable(); Session["RowsCount"] = dt.Rows.Count; Session["DataTable"] = dt; //Should be avoided since session are per user. gridView.DataSource = dt; gridView.DataBind();
Later you can access the
Count from the session.