When I search, my grid displays 20 records. If I have paging enabled and the page size is set to 20, clicking on the 2nd page refreshes the entire grid, showing me the 1st page again.
How can I view the last 10 records (11-20) when there are 20 total records and the page size is set to 10?
Below is the client-side code of the grid:
<div id="divApplication" runat="server">
<asp:GridView ID="gvApplication"
runat="server"
AutoGenerateColumns="false"
AllowPaging="true"
AllowSorting="True"
AlternatingRowStyle-CssClass="alt"
PagerStyle-CssClass="pgr"
OnPageIndexChanging="OnPageIndexChanging"
CssClass="table table-bordered table-striped"
PageSize="10" Width="50%">
<Columns>
<asp:TemplateField HeaderText='Application' HeaderStyle-VerticalAlign="Middle">
<HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle" CssClass="chkbox" />
<ItemTemplate>
<asp:Label ID="lblFirstName" runat="server"
att='<%#DataBinder.Eval(Container.DataItem,"ID")%>' Text='<%# SetLinkCodeApplication(Convert.ToInt64(DataBinder.Eval(Container.DataItem,"ID")),DataBinder.Eval(Container.DataItem,"Application").ToString()) %>'></asp:Label>
</ItemTemplate>
<ItemStyle Width="3%" HorizontalAlign="left" />
</asp:TemplateField>
</Columns>
</asp:GridView>
</div>
Server-side code for binding the grid:
public void fncfillApplication()
{
try
{
DataSet ds = new DataSet();
ds.ReadXml(Server.MapPath("Application.xml"));
if (ds.Tables[0].Rows.Count != 0)
{
gvApplication.DataSource = ds;
gvApplication.DataBind();
}
}
catch (Exception ex)
{
ex.Message.ToString();
}
}
protected void OnPageIndexChanging(object sender, GridViewPageEventArgs e)
{
gvApplication.PageIndex = e.NewPageIndex;
this.fncfillApplication();
}
Method for setting link code in edit mode:
public string SetLinkCodeApplication(Int64 sId, string sName)
{
string functionReturnValue = null;
try
{
functionReturnValue = "<a href=javascript:fncopenEditPopUpApplication(" + sId + ")>" + sName.Trim() + "</a>";
//return functionReturnValue;
}
catch (Exception ex)
{
throw;
}
return functionReturnValue;
}
I am using XML Datasource to bind data.