Link to home
Start Free TrialLog in
Avatar of minglelinch
minglelinch

asked on

GridView Row Height

I have a gridview and a style defined below. The gridview is bound to a dataset dynamically. Although I have set .gridstyle in GridView, the grid row height is still changable, because some columns contains multpiple words and the worlds can be displayed one word a line. This gridview is only for displaying and without add/edit/delete functionalities.

How can I fix the height of each row? Where should I put .gridstyle to fix the cell height?

    <style type="text/css">
       
        .gridstyle { height: 20px; }

    </style>

<asp:GridView ID="GridView2" runat="server" BackColor="#FFFFFF" CssClass ="gridstyle"
                    ForeColor="#5078B3" BorderStyle="Solid" BorderColor="#5078B3" >                   
          <headerstyle backcolor="#BF88FE"  forecolor="#5078B3"/>
          <footerstyle backcolor="#BF88FE"  forecolor="#3A5FCD"/>                
          <PagerStyle HorizontalAlign="Center" />                    
           <AlternatingRowStyle BackColor="#F0F0F0" />
</asp:GridView>
Avatar of BurnieP
BurnieP
Flag of Canada image

You can try

<asp:GridView ID="GridView2" runat="server" BackColor="#FFFFFF" CssClass ="gridstyle"
                    ForeColor="#5078B3" BorderStyle="Solid" BorderColor="#5078B3" >     
           <RowStyle  Height="20px" Wrap="false" />              
          <headerstyle backcolor="#BF88FE"  forecolor="#5078B3"/>
          <footerstyle backcolor="#BF88FE"  forecolor="#3A5FCD"/>                
          <PagerStyle HorizontalAlign="Center" />                    
           <AlternatingRowStyle BackColor="#F0F0F0" />
</asp:GridView>
Avatar of Miguel Oz
Use CssClass  to call css:
<asp:GridView ID="GridView2" runat="server" BackColor="#FFFFFF" CssClass ="gridstyle"
                    ForeColor="#5078B3" BorderStyle="Solid" BorderColor="#5078B3" >     
           <RowStyle  CssClass="gridstyle" />              
          <headerstyle backcolor="#BF88FE"  forecolor="#5078B3"/>
          <footerstyle backcolor="#BF88FE"  forecolor="#3A5FCD"/>                
          <PagerStyle HorizontalAlign="Center" />                    
           <AlternatingRowStyle BackColor="#F0F0F0" />
</asp:GridView>
Avatar of minglelinch
minglelinch

ASKER

I tried <RowStyle  Height="20px" Wrap="false" /> , it's not working. Any other ways?
I just tried <RowStyle  CssClass="gridstyle" />, it's still not working. Any other way? Thanks.
ASKER CERTIFIED SOLUTION
Avatar of Miguel Oz
Miguel Oz
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Yes, it's in head section and it's unique. Most rows are fine, except rows having multiple words in a cell shows higher size, as the multiple words take two or three lines.
I've requested that this question be deleted for the following reason:

This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
I'll post the answer.
THanks for the comment