不明白为什么gridview寻呼号码相距很远而不是彼此相邻 [英] Dont understand why gridview paging number are far apart instead of being next to each other

查看:68
本文介绍了不明白为什么gridview寻呼号码相距很远而不是彼此相邻的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

点击此处查看我得到的问题的图片,传呼号码太远

[ ^ ]





 <   pre  >  <   asp:GridView     ID   =  GridView1    runat   =  server    CssClass   =  fixedColWidth    CellPadding   =  0     ForeColor   = < span class =code-keyword>#333333   高度  =  273px    AutoGenerateEditButton   =  True      OnRowEditing   =  GridView1_RowEditing                 < span class =code-attribute>   

< span class =code-attribute> OnRowCancelingEdit = GridView1_RowCancelingEdit

OnRowUpdating = GridView1_RowUpdating

OnPageIndexChanging = GridView1_PageIndexChanging AllowPaging = True PageSize = 1000 >
< AlternatingRowStyle BackColor = 白色 ForeColor = #284775 / >
<% -
< Columns> ;
< asp:CommandField ShowEditButton =TrueShowDeleteButton =True/>
< /列>
- %>
< EditRowStyle BackColor = #999999 / >
< FooterStyle BackColor = #5D7B9D 字体-Bold = True ForeColor = 白色 / >
< HeaderStyle BackColor = #5D7B9D 字体粗体 = True ForeColor = 白色 / >
< PagerStyle BackColor = #284775 ForeColor = 白色 Horizo​​ntalAlign = / >
< RowStyle BackColor = #F7F6F3 ForeColor = #333333 / >
< < span class =code-leadattribute> SelectedRowStyle BackColor = #E2DED6 Font-Bold = True ForeColor = #333333 / >
< SortedAscendingCellStyle BackColor = #E9E7E2 / >
< SortedAscendingHeaderStyle < span class =code-attribute> BackColor = #506C8C / >
< SortedDescendingCellStyle BackColor = #FFFDF8 / >
< SortedDescendingHeaderStyle BackColor = #6F8DAE / >





我的Css课程对于gridview,下面用于给列的最大和最小宽度为150px,因为我有相关的下拉列表,它们是相同的px大小。



< style> 
.fixedColWidth td
{
min-width:150px;
max-width:150px;
}
< / style>





我尝试过:



i尝试从堆栈溢出执行此操作,但随后它删除了150 px的列大小。

asp.net - 页码太远了GridView - 堆栈溢出 [ ^ ]

解决方案

查看生成的HTML。您将看到寻呼机呈现为主 GridView 表底部行中的子表:

 <     < span class =code-attribute> class   =  fixedColWidth    ...  >  
...
< tr >
< td colspan = ... < span class =code-keyword>>
< table >
< < span class =code-leadattribute> tr >
< td >
1
< / td >
< td >
< a .. 。 > 2 < / a >
< / td >
...
< / tr >
< / table >
< / td >
< / tr >
< / table >



你的CSS规则说明了主表中的任何< td> 的固定宽度应为150px。这包括嵌套在寻呼机表中的< td>



你需要更改你的规则,以便它只适用于 GridView 的直接子节点。 (根据您的设置,您可能需要考虑< thead> / < tbody> 以及。)

 fixedColWidth  >   tr  >   td 
fixedColWidth > tbody > tr > td
fixedColWidth > thead > tr > td ,
fixedColWidth > tfoot > tr > td
{
min-width 150px;
max -width 150px;
}


Click here for a picture of the issue i am getting with the paging number being too far

[^]


<pre><asp:GridView ID="GridView1" runat="server" CssClass="fixedColWidth" CellPadding="0" ForeColor="#333333" Height="273px" AutoGenerateEditButton="True"  OnRowEditing="GridView1_RowEditing"         

        OnRowCancelingEdit="GridView1_RowCancelingEdit" 

        OnRowUpdating="GridView1_RowUpdating"

        OnPageIndexChanging="GridView1_PageIndexChanging" AllowPaging="True" PageSize="1000">
              <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
                <%--<Columns>
                    <asp:CommandField ShowEditButton="True" ShowDeleteButton="True" />
                </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="Left"/>
              <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" />



My Css class for the gridview is below which is used to give the columns a max and min width of 150px because i have dropdowns correlated which are the same px size.

<style>
     .fixedColWidth td
     {
     min-width : 150px;
     max-width : 150px;
            }
</style>



What I have tried:

i tried to do this from stack overflow but then it removes the column size of 150 px.
asp.net - page numbers are too far in GridView - Stack Overflow[^]

解决方案

Look at the generated HTML. You'll see that the pager is rendered as a child table within a row at the bottom of the main GridView table:

<table class="fixedColWidth" ...>
    ...
    <tr>
        <td colspan="...">
            <table>
                <tr>
                    <td>
                        1
                    </td>
                    <td>
                        <a ...>2</a>
                    </td>
                    ...
                </tr>
            </table>
        </td>
    </tr>
</table>


Your CSS rule says that any <td> within the main table should have a fixed width of 150px. This includes the <td>s nested within the pager table.

You'll need to change your rule so that it only applies to the immediate children of the GridView. (Depending on your settings, you might need to account for a <thead> / <tbody> as well.)

.fixedColWidth > tr > td,
.fixedColWidth > tbody > tr > td,
.fixedColWidth > thead > tr > td,
.fixedColWidth > tfoot > tr > td
{
    min-width: 150px;
    max-width: 150px;
}


这篇关于不明白为什么gridview寻呼号码相距很远而不是彼此相邻的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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