简体   繁体   中英

Goto GridView section after click edit button

I use c# GridView control to show data from database. When I click in edit button page is reload and field is editable, but in my page, GridView is at the bottom of the page. I have few big table and can't place GridView higher. How I can achive effect, that when I click on edit button, after reload, user will be in gridview section insted top of page?

Thank you in advance for your help.

You set the MaintainScrollPositionOnPostBack property in the @Page directive to true .

The page directive is the first line of your .aspx code. Add the attribute here with the value of "true"

<%@ Page Language="C#" MaintainScrollPositionOnPostback="true"

The page will now maintain the scroll position and upon post pack the page will return to that scroll position.

The property can also be set programmatically in the page load event:

this.MaintainScrollPositionOnPostBack = true;

You can use MaintainScrollPositionOnPostBack on your Page_Load method:

protected void Page_Load(object sender, EventArgs e)
{
    this.MaintainScrollPositionOnPostBack = true;
    .....
}

MaintainScrollPositionOnPostBack Gets or sets a value indicating whether to return the user to the same position in the client browser after postback.

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.

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