Currently I created GridView and can click change page as below.
However, I want to disable refresh whole page when page of GridView is changed.
Could you please help to suggest me?
.aspx
<body>
<form runat="server">
<asp:GridView ID="gridView1" runat="server" AutoGenerateColumns="true" AllowPaging="true" PageSize="2" OnPageIndexChanging="gridView1_OnPageIndexChanging" CssClass="table table-sm table-striped table-bordered table-hover table-responsive-sm small">
</asp:GridView>
</form>
</body>
.aspx.cs
protected void Page_Load(object sender, EventArgs e)
{
DataTable dataTable1 = new DataTable();
dataTable1.Columns.Add("Column 1");
dataTable1.Columns.Add("Column 2");
dataTable1.Rows.Add("1", "1");
dataTable1.Rows.Add("2", "2");
dataTable1.Rows.Add("3", "3");
dataTable1.Rows.Add("4", "4");
gridView1.DataSource = dataTable1;
gridView1.DataBind();
}
protected void gridView1_OnPageIndexChanging(object sender, GridViewPageEventArgs e)
{
gridView1.PageIndex = e.NewPageIndex;
gridView1.DataBind();
}
I think you'have missed this...
<body>
<form runat="server">
<asp:ScriptManager ID="SC1" runat="server"></asp:ScriptManager>
<asp:UpdatePanel ID="updPnl" runat="server">
<ContentTemplate>
<asp:GridView ID="gridView1" runat="server" AutoGenerateColumns="true" AllowPaging="true" PageSize="2" OnPageIndexChanging="gridView1_OnPageIndexChanging" CssClass="table table-sm table-striped table-bordered table-hover table-responsive-sm small">
</asp:GridView>
</ContentTemplate>
</asp:UpdatePanel>
</form>
</body>
Note:- you have to add Update Panel
if your problem is still not solved...then refer this link
Actually you cannot 'DISABLE' page reloads in standard browsers, you can just add a "TIP" for the user to see who can choose not to reload the page, see:
https://developer.mozilla.org/zh-CN/docs/Web/API/Window/onunload
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.