如何使gridview文本与中间对齐并且更流畅?

时间:2017-07-24 03:09:40

标签: html css asp.net twitter-bootstrap gridview

对不起,我在这里是菜鸟。我试图使我的文本与中间对齐,而不是粘在桌子的边框上。但是,我尝试了很多代码水平对齐,cssclass在属性和内容中保持不对齐。 那么,我如何流动我的gridview或使gridview文本对齐而不是让它如此抽筋? Image not align

<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>

2 个答案:

答案 0 :(得分:0)

试试这段代码:

<RowStyle HorizontalAlign="Center"></RowStyle>

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

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

答案 1 :(得分:0)

[ { "level" : "warning", "schema" : { "loadingURI" : "#", "pointer" : "/properties/alpha/properties/beta/oneOf/0/properties/ObjA/properties/items" }, "domain" : "syntax", "message" : "the following keywords are unknown and will be ignored: [a, b, c]", "ignored" : [ "a", "b", "c" ] }, { "level" : "warning", "schema" : { "loadingURI" : "#", "pointer" : "/properties/alpha/properties/beta/oneOf/0/properties/ObjA/properties/items" }, "domain" : "syntax", "message" : "the following keywords are unknown and will be ignored: [a, b, c]", "ignored" : [ "a", "b", "c" ] }, { "level" : "warning", "schema" : { "loadingURI" : "#", "pointer" : "/properties/alpha/properties/beta/oneOf/0/properties/ObjA/properties/items" }, "domain" : "syntax", "message" : "the following keywords are unknown and will be ignored: [a, b, c]", "ignored" : [ "a", "b", "c" ] }, { "level" : "error", "schema" : { "loadingURI" : "#", "pointer" : "/properties/alpha/properties/beta" }, "instance" : { "pointer" : "/alpha/beta" }, "domain" : "validation", "keyword" : "oneOf", "message" : "instance failed to match exactly one schema (matched 0 out of 1)", "matched" : 0, "nrSchemas" : 1, "reports" : { "/properties/alpha/properties/beta/oneOf/0" : [ { "level" : "warning", "schema" : { "loadingURI" : "#", "pointer" : "/properties/alpha/properties/beta/oneOf/0/properties/ObjA/properties/items" }, "domain" : "syntax", "message" : "the following keywords are unknown and will be ignored: [a, b, c]", "ignored" : [ "a", "b", "c" ] }, { "level" : "error", "schema" : { "loadingURI" : "#", "pointer" : "/properties/alpha/properties/beta/oneOf/0" }, "instance" : { "pointer" : "/alpha/beta" }, "domain" : "validation", "keyword" : "type", "message" : "instance type (string) does not match any allowed primitive type (allowed: [\"object\"])", "found" : "string", "expected" : [ "object" ] } ] } } ] 中的center rag中添加您的控件:

templatefield