日期:2014-05-18  浏览次数:20488 次

将一个datagrid放在table中实现内部滚动,如何实现行选择的时候定位??
通过下面的代码把datagrid放在table中实现内部滚动,当选中某一行的时候,显示的数据datagrid的总是会跳到datagrid列表的最上面,当数据多的时候根本看不到选择行的位置,如何让选中的时候datagrid定位在选中的位置呢?而不跳到最上面!
<table   borderColor= "#8e8e8e "   cellSpacing= "0 "   borderColorDark= "#ffffff "   cellPadding= "2 "
width= "820 "   border= "0 ">
<TR>
<TD   colSpan= "2 ">
<div   id= "div1 "   style= "BORDER-RIGHT:       #ffffff   thin   solid;   BORDER-TOP:       #ffffff   thin   solid;   MARGIN-TOP:       0px;   PADDING-LEFT:       0px;   MARGIN-LEFT:       0px;   OVERFLOW:       auto;   BORDER-LEFT:       #ffffff   thin   solid;   WIDTH:       100%;   PADDING-TOP:       0px;   BORDER-BOTTOM:       #ffffff   thin   solid;   HEIGHT:       400px "
noWrap>
<asp:datagrid   id= "dgGrid "   runat= "server "   Width= "100% "   AllowPaging= "True "   AllowSorting= "True "   AutoGenerateColumns= "False "
HorizontalAlign= "Left "   CssClass= "Grid "   DESIGNTIMEDRAGDROP= "85 "   PageSize= "20 ">
<SelectedItemStyle   CssClass= "GridSelItem "> </SelectedItemStyle>
<AlternatingItemStyle   CssClass= "GridAltItem "> </AlternatingItemStyle>
<ItemStyle   CssClass= "GridItem "> </ItemStyle>
<HeaderStyle   CssClass= "GridHeader "> </HeaderStyle>
<Columns>
<asp:BoundColumn   DataField= "ZTname "   SortExpression= "ZT "   HeaderText= "状态 ">
<HeaderStyle   HorizontalAlign= "Center "   Width= "15% "> </HeaderStyle>
<ItemStyle   HorizontalAlign= "Center "> </ItemStyle>
</asp:BoundColumn>
<asp:BoundColumn   DataField= "ND "   SortExpression= "ND "   HeaderText= "年度 ">
<HeaderStyle   HorizontalAlign= "Center "   Width= "15% "> </HeaderStyle>
<ItemStyle   HorizontalAlign= "Center "> </ItemStyle>
</asp:BoundColumn>
<asp:BoundColumn   DataField= "ZS "   SortExpression= "ZS "   HeaderText= "周数 ">
<HeaderStyle   HorizontalAlign= "Center "   Width= "15% "> </HeaderStyle>
<ItemStyle   HorizontalAlign= "Center "> </ItemStyle>
</asp:BoundColumn>

</Columns>
<PagerStyle   NextPageText= " "   PrevPageText= " "   HorizontalAlign= "Right "   CssClass= "GridPager "> </PagerStyle>
</asp:datagrid> </div>
</TD>
</TR> </table>

------解决方案--------------------
当选中一行的时候会走后台,所以页面会重刷一下

我想用锚定位可以实现,不过我也没做过例子,你可以去试一下!下面是个简单的锚定位的例子!

<a name= "#top " href= "#bott