简体   繁体   English

Bootstrap 4:当 GridView 的页面改变时禁用刷新整个页面

[英]Bootstrap 4: Disable refresh whole page when page of GridView is changed

Currently I created GridView and can click change page as below.目前我创建了 GridView 并且可以点击下面的更改页面。
However, I want to disable refresh whole page when page of GridView is changed.但是,当 GridView 的页面发生更改时,我想禁用刷新整个页面。
Could you please help to suggest me?你能帮我推荐一下吗?
.aspx .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 .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();
}

Output Output
Bootstrap 4:更改 GridView 页面时禁用刷新整个页面

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如果您的问题仍未解决...请参考此链接

https://www.aspsnippets.com/Articles/Paging-and-Sorting-without-PostBack-Refresh-in-ASPNet-GridView.aspx https://www.aspsnippets.com/Articles/Paging-and-Sorting-without-PostBack-Refresh-in-ASPNet-GridView.aspx

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 https://developer.mozilla.org/zh-CN/docs/Web/API/Window/onunload

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM