Solved

GridView Row Height

Posted on 2010-11-28
10
593 Views
Last Modified: 2012-05-10
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>
0
Comment
Question by:minglelinch
10 Comments
 
LVL 16

Expert Comment

by:BurnieP
ID: 34226614
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>
0
 
LVL 35

Expert Comment

by:Miguel Oz
ID: 34226909
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>
0
 
LVL 1

Author Comment

by:minglelinch
ID: 34227188
I tried <RowStyle  Height="20px" Wrap="false" /> , it's not working. Any other ways?
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 1

Author Comment

by:minglelinch
ID: 34227202
I just tried <RowStyle  CssClass="gridstyle" />, it's still not working. Any other way? Thanks.
0
 
LVL 35

Accepted Solution

by:
Miguel Oz earned 500 total points
ID: 34227552
My code works OK in my sample page. Is the style below defined on the HEAD section of your page?
<HEAD>
  <style type="text/css">
       
        .gridstyle { height: 20px; }

    </style>
</HEAD>
also, Is the gridstyle name unique?
0
 
LVL 1

Author Comment

by:minglelinch
ID: 34239012
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.
0
 
LVL 5

Expert Comment

by:knowlton
ID: 36119197
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.
0
 
LVL 1

Author Comment

by:minglelinch
ID: 36119198
I'll post the answer.
0
 
LVL 1

Author Closing Comment

by:minglelinch
ID: 36119200
THanks for the comment
0

Featured Post

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.

832 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question