GridView paging problem!

人走茶凉 提交于 2020-01-06 21:12:12

问题


I enabled paging in my gridview. It pages normally, but when I display 3 items instead of 10, the rows height changes proportionally to suit the gridview height. How can I make the rows be in fixed height! no matter how many items i have on a particular page in Gridview


回答1:


Don't specify a height for the gridview.

If your rows are larger from columns which have a lot of text, then use maybe something like this around your content:

<div style="overflow-y:scroll; width: 200px; height: 100px;">
    <%# Eval("ColumnName") %>
</div>

Better to move into a css class instead of style but that is basically what you need.




回答2:


You can set the row height by setting RowStyle-Height within the GridView tag itself.. Also you can set the styles of each cell including the header cell by setting attributes in each TemplateField (ItemStyle-Height etc). see the code below,

<asp:GridView ID="gvwID" runat="server" AutoGenerateColumns="false" 
    RowStyle-Height="50"  Width="100%">
    <Columns>
        <asp:TemplateField ItemStyle-Height="50"  HeaderStyle-Height="110" 
            HeaderText="Releases" ItemStyle-VerticalAlign="Top" >
            <ItemTemplate>
                //data binding section
            </ItemTemplate>
        </asp:TemplateField>
    </Columns>
</asp:GridView>

Hope this helps you...



来源:https://stackoverflow.com/questions/6555956/gridview-paging-problem

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!