1

我正在尝试在我的页面中使用可滚动的 GridView,但问题是标题和字段或单元格内容未对齐。换句话说,我的单元格或字段未与标题对齐;它们稍微向右移动。在我应用 JQuery Scrollable 函数之前,一切都已完美对齐,现在我不知道如何解决这个问题。有人可以帮忙吗?谢谢这是我的代码

<script src="../Scripts/jquery-1.8.1.min.js" type="text/javascript"></script>
<script src="../Scripts/ScrollableGridViewPlugin_ASP.NetAJAXmin.js" type="text/javascript"></script>
<script type="text/javascript">
    $(document).ready(function () {
        $('#<%=GV_Detail.ClientID %>').Scrollable({
            ScrollHeight: 300,
            IsInUpdatePanel: true
        });
    });
</script>

</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" Runat="Server">
 <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
<div>
<asp:UpdatePanel ID="up" runat="server">
    <ContentTemplate>
    <asp:GridView ID="GV_Detail" runat="server" 
        AllowSorting="True" AutoGenerateColumns="False" BackColor="White" 
        BorderColor="#CCCCCC" BorderStyle="None" BorderWidth="1px" CellPadding="3" 
        DataSourceID="GV_Detail_DS">
        <Columns>
                <asp:BoundField DataField="ContactName" HeaderText="Contact Name" />
                <asp:BoundField DataField="City" HeaderText="City" />
                <asp:BoundField DataField="Country" HeaderText="Country" />
                </Columns> 
        <FooterStyle BackColor="White" ForeColor="#000066" />
        <HeaderStyle BackColor="#006699" Font-Bold="True" ForeColor="White" />
        <PagerStyle BackColor="White" ForeColor="#000066" HorizontalAlign="Left" />
        <RowStyle ForeColor="#000066" />
        <SelectedRowStyle BackColor="#669999" Font-Bold="True" ForeColor="White" />
        <SortedAscendingCellStyle BackColor="#F1F1F1" />
        <SortedAscendingHeaderStyle BackColor="#007DBB" />
        <SortedDescendingCellStyle BackColor="#CAC9C9" />
        <SortedDescendingHeaderStyle BackColor="#00547E" />
    </asp:GridView>
    <asp:SqlDataSource ID="GV_Detail_DS" runat="server" 
        ConnectionString="<%$ ConnectionStrings:MyConnectionString %>" 
        SelectCommand="SELECT contactname, city, country from my table">
    </asp:SqlDataSource>

     </ContentTemplate>
</asp:UpdatePanel>
</div>
4

2 回答 2

1

也许你可以试试我的解决方案。我正在测试所有单元格对齐。

带有 jQ​​uery 的 GridViewScroll

在此处输入图像描述

于 2012-12-14T16:46:37.100 回答
0

要将网格与标题对齐,请删除单元格填充,然后尝试一下。

或者,您可以使用上面的插件。它在大多数情况下都有效,但在某些情况下会导致双重回发。

于 2013-10-29T05:51:47.730 回答