gridview的列宽随着寻呼号而增加

时间:2015-03-05 12:13:56

标签: c# asp.net gridview

- 第一列宽度随着网格视图中的分页号而增加    第1列的宽度随着页码的增加而增加    第1列中的额外空白区域   - 请告诉我如何修复分页问题,​​我必须更改以修复页面大小问题?

 <asp:GridView ID="GrdKeyWord" SkinID="gridviewSkin" AutoGenerateColumns="false" runat="server"
        OnRowCommand="GrdKeyWord_RowCommand" 
        OnRowCancelingEdit="GrdKeyWord_RowCancelingEdit"  AllowPaging="true" OnPageIndexChanging = "OnPaging" OnPageIndexChanged="OnPageChanged" PagerSettings-PageButtonCount="20" PageSize="10" >
           <PagerStyle CssClass="gridViewPager" Font-Underline="false" BorderColor="White" BorderStyle="None" BorderWidth="0"  />

        <Columns>
        <asp:TemplateField>
                <HeaderTemplate>
                    Assign To
                </HeaderTemplate>
                <ItemTemplate>
                    <asp:Label ID="lbl_UserName" runat="server" Text='<%# Eval("UserName") %>'></asp:Label>
                </ItemTemplate>
                <EditItemTemplate>

                     <asp:HiddenField ID="hiddUserId" runat="server" Value='<%# Eval("UserName") %>' />
                    <asp:DropDownList ID="Gv_DdlUserName" runat="server">
                    </asp:DropDownList>
                </EditItemTemplate>
            </asp:TemplateField>
         <asp:BoundField DataField="Projectname" HeaderText="Project Name" ReadOnly="true" />
            <asp:TemplateField>
                <HeaderTemplate>
                    Keyword
                </HeaderTemplate>
                <ItemTemplate>
                    <asp:HiddenField ID="hiddenId" runat="server" Value='<%# Eval("KeywordID") %>' />
                    <asp:Label ID="lbl_Keyword" runat="server" Text='<%# Eval("KeyWord") %>'></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField>
                <HeaderTemplate>
                    Start Date
                </HeaderTemplate>
                <ItemTemplate>
                    <asp:Label ID="lbl_StartDate" runat="server" Text='<%# Eval("ProjAssignDate") %>'></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField>
                <HeaderTemplate>
                    Target Date
                </HeaderTemplate>
                <ItemTemplate>
                    <asp:Label ID="lbl_TargetDate" runat="server" Text='<%# Eval("TargetDate") %>'></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField>
                <HeaderTemplate>
                    Exp Position
                </HeaderTemplate>
                <ItemTemplate>
                    <asp:Label ID="lbl_Position" runat="server" Text='<%# Eval("PositionExp") %>'></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField>
                <HeaderTemplate>
                    Today's pos
                </HeaderTemplate>
                <ItemTemplate>
                    <asp:Label ID="lbl_TodayPos" runat="server" Text='<%# Eval("CurrentPosition") %>'></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Change">
                <ItemTemplate>
                    <asp:Button ID="btn_Change" Text="Change" ForeColor="#4377A8" Font-Bold="true" runat="server"
                        CommandName="Change" CommandArgument='<%# ((GridViewRow) Container).RowIndex %>'/>


                    <asp:Button ID="Cancel" Text="Cancel" ForeColor="Maroon" Font-Bold="true" runat="server"
                        CommandName="Cancel" CommandArgument='<%# ((GridViewRow) Container).RowIndex %>' Visible="false" />
                </ItemTemplate>
            </asp:TemplateField>
        </Columns>
    </asp:GridView>

enter image description here

2 个答案:

答案 0 :(得分:0)

尝试删除

 <PagerStyle CssClass="gridViewPager" Font-Underline="false" BorderColor="White" BorderStyle="None" BorderWidth="0"  />

或添加

max-width属性到gridViewPager css类。

答案 1 :(得分:0)

Gridview将Pager作为Gridview中的附加行呈现。它是一行,带有一个td条目,其colspan由GridView控件调整为必要条件。寻呼机实际上是一个嵌入式表格:

<div>
  <table cellspacing="0" rules="all" border="1" id="GridView1" style="border-collapse:collapse;">
    <tbody>
      <tr><th scope="col">column header 1</th><th scope="col">column header 2</th></tr>
      <tr><td>1002</td><td>0</td></tr>

      <!-- Begin Pager Row of Gridview -->
      <tr>
        <td colspan="2"> <!-- colspan will adjust accordingly -->
          <table>  
            <tbody>
              <tr> 
                <td><span>1</span></td>
                <td><a href="javascript:__doPostBack('GridView1','Page$2')">2</a></td>
                <td><a href="javascript:__doPostBack('GridView1','Page$3')">3</a></td>
              </tr>
            </tbody>
          </table>
        </td>
      </tr>
    </tbody>
  </table>
</div>

根据您的Gridview,如果我计算正确,您的寻呼机行的colspan应为8。

渲染的html是什么样的?你在做任何jquery或JS操作吗?