首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >如何让gridview文本居中对齐,更加流畅?

如何让gridview文本居中对齐,更加流畅?
EN

Stack Overflow用户
提问于 2017-07-24 11:09:40
回答 2查看 840关注 0票数 1

对不起,我是新手。我试着让我的文本对齐到中间,而不是粘在表格的边框上。然而,我尝试了许多代码水平对齐,cssclass中的属性和内容保持不在中间对齐。那么,我如何使我的网格视图流畅,或者让网格视图文本对齐而不让它如此抽筋呢?

代码语言:javascript
运行
复制
<asp:GridView ID="gvViewFeed" runat="server" AutoGenerateColumns="False" AutoGenerateSelectButton="True" CellPadding="4" style="align-items:center;" CssClass="table-bordered" DataKeyNames="FeedbackID" ForeColor="#333333" GridLines="None" Width="100%" OnSelectedIndexChanged="gvViewFeed_SelectedIndexChanged" HeaderStyle-CssClass="centerHeaderText" BorderStyle="Solid" CellSpacing="2" HorizontalAlign="Justify">
            <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
            <Columns>
                <asp:BoundField DataField="FeedbackID" HeaderText="FeedbackID" >
                <ItemStyle Wrap="True" HorizontalAlign="Right" />
                </asp:BoundField>
                <asp:BoundField DataField="MemberID" HeaderText="MemberID" />
                <asp:BoundField DataField="DateTimePosted" HeaderText="DateTimePosted" />
                <asp:BoundField DataField="Title" HeaderText="Title" />
                <asp:BoundField DataField="Text" HeaderText="Text" />
            </Columns>
            <EditRowStyle BackColor="#999999" />
            <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
            <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
            <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
            <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
            <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
            <SortedAscendingCellStyle BackColor="#E9E7E2" />
            <SortedAscendingHeaderStyle BackColor="#506C8C" />
            <SortedDescendingCellStyle BackColor="#FFFDF8" />
            <SortedDescendingHeaderStyle BackColor="#6F8DAE" />
        </asp:GridView>
    </p>
    <asp:GridView ID="gvResponse" runat="server" AutoGenerateColumns="False" CellPadding="4" CssClass="Table" ForeColor="#333333" GridLines="None" Width="80%" style="align-items:center;">
        <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
        <Columns>
            <asp:BoundField DataField="ResponseID" HeaderText="ResponseID" />
            <asp:BoundField DataField="DateTimePosted" HeaderText="DateTimePosted" />
            <asp:BoundField DataField="Text" HeaderText="Text" />
        </Columns>
        <EditRowStyle BackColor="#999999" />
        <EmptyDataTemplate>
            No Record Found!
        </EmptyDataTemplate>
        <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
        <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
        <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
        <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
        <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
        <SortedAscendingCellStyle BackColor="#E9E7E2" />
        <SortedAscendingHeaderStyle BackColor="#506C8C" />
        <SortedDescendingCellStyle BackColor="#FFFDF8" />
        <SortedDescendingHeaderStyle BackColor="#6F8DAE" />
    </asp:GridView>
EN

回答 2

Stack Overflow用户

发布于 2017-07-24 11:17:45

尝试以下代码:

代码语言:javascript
运行
复制
<RowStyle HorizontalAlign="Center"></RowStyle>

<ItemStyle HorizontalAlign="Center"></ItemStyle>

有关更多信息,请查看MSDN GridView examples。

票数 0
EN

Stack Overflow用户

发布于 2017-07-24 21:09:22

templatefieldcenter rag中添加控件

代码语言:javascript
运行
复制
<ItemTemplate>
    <center>
        <asp:Button ID="btnEdit" runat="server" CssClass="btn btn-primary btn-sm" Text="EDIT" />
        <asp:Button ID="btnDelete" runat="server" CssClass="btn btn-danger btn-sm" Text="DELETE" />
    </center>
</ItemTemplate>
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/45272045

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档