you could set paging information to Total1 text in onSelectedData
handler as the following
protected void onSelectedData(object sender, SqlDataSourceStatusEventArgs e)
{
int startRowOnPage = (GridView1.PageIndex * GridView1.PageSize) + 1;
int lastRowOnPage = startRowOnPage + GridView1.Rows.Count - 1;
int totalRows = e.AffectedRows;
Total1.Text = "Showing " + startRowOnPage.ToString() +
" - " + lastRowOnPage + " of " + totalRows;
}
So you SQLDataSource should be like this sample:
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
OnSelected="onSelectedData"
... >
</asp:SqlDataSource>
And you don't need to do anything for paging information in GridView1_DataBound
.
I mean you could remove OnDataBound="GridView1_DataBound"
out from your GridView declaration.
EDITED
To set the PageSize
, you should set a default value for it such as the following sample:
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
if (Convert.ToInt32(DropDownList1.SelectedValue) != null)
GridView1.PageSize = Convert.ToInt32(DropDownList1.SelectedValue);
}
}