Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

GridView Row Height

Posted on 2010-11-28
10
Medium Priority
?
603 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 36

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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
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 36

Accepted Solution

by:
Miguel Oz earned 2000 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:Tom 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

715 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