I have paging enabled in my gridview…
I need this in button click event
- gridview total row count
- loop through all the rows in foreach
but it's only working for the current gridview page…help
protected void Button5_Click(object sender, EventArgs e)
{
int[] no = new int[GridView2.Rows.Count];
int i = 0;
foreach (GridViewRow row in GridView2.Rows)
{
Label l = (Label)row.FindControl("Label2");
if (l.Text == "Unpaid")
{
int productID = Convert.ToInt32(GridView2.DataKeys[row.RowIndex].Value);
no[i] = productID;
i++;
}
}
}
Best Answer
to achieve you have to disable paging before loop. rebind the grid & perform loop . Then enable paging & bind the grid again.