如何使标题标题成为asp:GridView的中心 [英] how to make heading title into the center in asp:GridView

查看:36
本文介绍了如何使标题标题成为asp:GridView的中心的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人知道如何在asp:GridView中将标题居中吗?

Does anyone know how can I center a title to the center in asp:GridView?

示例:

和我的代码如下:

<table border="0" width="500">
<tr>
    <td width="450px" align="center">
            <asp:GridView ID="grid" runat="server" AutoGenerateColumns="False"
              DataSourceID="dsTest" DataKeyNames="id"
              CellPadding="6" GridLines="None" AllowPaging="True" PageSize="20" AllowSorting="True" Width="450px">
              <Columns>
                <asp:TemplateField HeaderText="   Address" SortExpression="suburb, street">
                  <ItemTemplate>
                        <a style='cursor:pointer'  href='#'>
                     <%# Eval("unit_number") %> <%# Eval("level_number") %> <%# Eval("street_number") %> <%# Eval("street") %>
                     <%# Eval("suburb") %> <%# Eval("postcode") %></a>
                  </ItemTemplate>
                </asp:TemplateField>
              </Columns>
</asp:GridView>
</td>
</tr>
</table>

有人知道我该如何向中心发送地址"?我试图在GridView的CSS中设置text-align:"center",但是它似乎对我不起作用

Does anyone know how can I make the 'Address' to the center instead? I have tried to set a text-align:"center" in css for GridView, but it's doesn't seem working for me

也...如果我想在左侧增加所有显示地址,有人知道我该怎么做吗?

Also... if I like to more all display address to the left, does anyone know how can I do it?

推荐答案

如果您正在使用Visual Studio 2015并像我一样创建"Web应用程序".这些选项均无效.主要是因为上述命令被Bootstrap.css文件中的调出覆盖.解决方法-在网页上插入表格后,您需要在解决方案资源管理器中的内容"文件夹下打开Bootstrap.css.我搜索了表格",发现在第1419行,有两个表格"样式被呼出,并围绕着"th"样式."th"是表头".默认情况下将其设置为"text-align:left;".只需将"left"更改为"center",一切正常.以下是我找到并更改的默认Bootstrap.css文件的片段.在我看来,它从1413行开始,到1426行结束.

If you are using Visual Studio 2015 and creating a "Web Application" as I did. None of these options work. Mostly because the above commands are being over-ridden by a call-out in the Bootstrap.css file. How to fix this - After inserting the table on the web page you need to open Bootstrap.css under the Content folder in Solution explorer. I did a search for "Table" and found that at line 1419, there were two "Table" styles called out that surrounded a "th" style. "th" being the "Table Header". It was set by default to "text-align: left;". Simply change "left" to "center" and all works fine. Below is a snippet from the default Bootstrap.css file that I found and altered. On mine it started at line 1413 and ended on line 1426.

table {
  max-width: 100%;
  background-color: transparent;
  text-align:center;
}
th {
  text-align: center;
}

.table {
  width: 100%;
  margin-bottom: 20px;
} 

希望这会有所帮助.

这篇关于如何使标题标题成为asp:GridView的中心的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆