Question: using gcc 4.5.1 in a 64bit x86 machine,I first create a.o as following:
g++ -fPIC -c a.cc -o a.o

then try to create liba.so as following:
g++ -static-libstdc++ -shared -W1,-soname,liba.so -o liba.so.1.0.0 a.o

but failed, with the following information:
relocation R\_X86\_64\_32S against `vtable for \_\_gnu\_cxx::stdio\_filebuf >' can not be used when making a shared object; recompile with -fPIC

I try to recompile libstdc++ library,with -fPIC added,but it failed anyway

Answer: 
Add `MaintainScrollPositionOnPostback` in your page directive.

```
<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" MaintainScrollPositionOnPostback ="true"%> 

```

Another way, use a scrollTop method of the DIV that wraps your GridView:

```
private void ScrollGrid()
{
    int intScrollTo = this.gridView.SelectedIndex * (int)this.gridView.RowStyle.Height.Value;
    string strScript = string.Empty;
    strScript += "var gridView = document.getElementById('" + this.gridView.ClientID + "');\n";
    strScript += "if (gridView != null && gridView.parentElement != null && gridView.parentElement.parentElement != null)\n";
    strScript += "  gridView.parentElement.parentElement.scrollTop = " + intScrollTo + ";\n";
    ScriptManager.RegisterClientScriptBlock(this.Page, this.GetType(), "ScrollGrid", strScript, true);
}

```

**EDIT:**
 This won't work for several reasons:

1) if the gridView is inside a NamingContainer control, like a Panel, because the Id on the client side won't be the `ClientId`. You need to use the `UniqueId` of teh control instead.

2) you can't trust the row height to calculate the scroll position. If the text in any column wraps to more than one line, or any row contains something higher than the style, the size of the row will be different

3) different browsers can have different behaviors. You're better of using jQuery `scrollTop()` and `scroll()` functions. To use them, you must use `scrollTop` on client side and set the value of a `HiddenControl` that can be read on server side to reset the position. You can't get the height of the rows in the browser until they are rendered on client side.
This worked for me, and required no ASP.NET AJAX, UpdatePanel or cookie, and a lot less JavaScript than other solutions I've seen.

```
<input type="hidden" runat="server" id="hdnScroll" value="0" />
<div style="height:600px; overflow-x:hidden; overflow-y:scroll">
  <asp:GridView runat="server" ID="myGridView" OnRowDataBound="myGridView_RowDataBound" OnSelectedIndexChanged="myGridView_SelectedIndexChanged">
...
</asp:GridView>
</div>

```

Then

```
protected void myGridView_SelectedIndexChanged(object sender, EventArgs e) {
    //if(gr != null) gr.SelectedRow.Cells[0].Focus(); // Only works on an editable cell

    hdnScroll.Value = (myGridView.SelectedIndex * (int)myGridView.RowStyle.Height.Value).ToString();
}

```

Finally back in the .aspx, to run upon postback

```
<script type="text/javascript">
$(function() {
  document.getElementById('<%=myGridView.ClientID%>').scrollTop = $('#hdnScroll').val();
});

```