将Gridview列的标题对齐到中心

时间:2017-06-05 03:40:13

标签: gridview center title text-alignment

我有GridView。 我试图将标题放在中心没有任何作品

 <asp:GridView ID="GridviewDataCoupon" runat="server" Style="text-align: center" Visible="false" ShowFooter="true" Width="99%"
                                AutoGenerateColumns="false">
                                <Columns>

                                <asp:TemplateField HeaderText="End Date" HeaderStyle-BackColor="#99CCCC">
                                        <ItemTemplate>
                                            <asp:Label ID="lbl4" runat="server" Text='<%# Eval("end_date") %>'>
                                            </asp:Label>
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                </Columns>

                                <FooterStyle BackColor="#99CCCC" ForeColor="#003399" />
                                <PagerStyle BackColor="#99CCCC" ForeColor="#003399" HorizontalAlign="Left" />
                                <AlternatingRowStyle BackColor="WhiteSmoke" ForeColor="Black" />
                                <RowStyle BackColor="White" ForeColor="Black" />
                                <SelectedRowStyle BackColor="#009999" Font-Bold="True" ForeColor="#CCFF99" />
                                <SortedAscendingCellStyle BackColor="#EDF6F6" />
                                <SortedAscendingHeaderStyle BackColor="#0D4AC4" />
                                <SortedDescendingCellStyle BackColor="#D6DFDF" />
                                <SortedDescendingHeaderStyle BackColor="#002876" />
                            </asp:GridView>

1 个答案:

答案 0 :(得分:0)

在其中一个SO问题

中找到了这个解决方案

你可以做这样的事情

尝试从EndroidQrCodeBundle: resource: "@EndroidQrCodeBundle/Controller/" type: annotation prefix: /qrcode 代码中为 $nesAry=array(); $nesAry["name"]="abc"; $nesAry["email"]="abc@email.com"; $nesAry1=array(); $nesAry1["name"]="abc1"; $nesAry1["email"]="abc1@email.com"; $nesAry2=array(); $nesAry2["name"]="abc2"; $nesAry2["email"]="abc2@email.com"; $responseAry = array(); $responseAry[0]=$nesAry; $responseAry[1]=$nesAry1; $responseAry[2]=$nesAry2; echo json_encode($responseAry); // here output like this => [{"name":"abc","email":"abc@email.com"},{"name":"abc1","email":"abc1@email.com"},{"name":"abc2","email":"abc2@email.com"}] unset($responseAry[1]); echo "------------removed 1--------"; echo json_encode($responseAry); // but here output like this => {"0":{"name":"abc","email":"abc@email.com"},"2":{"name":"abc2","email":"abc2@email.com"}} 添加CssClass,并为您的班级分配以下样式。

GridView

这会将所有列文本设置为gridview

的中心