Solved

GridView Row Height

Posted on 2010-11-28
10
591 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
 
LVL 1

Author Comment

by:minglelinch
ID: 34227202
I just tried <RowStyle  CssClass="gridstyle" />, it's still not working. Any other way? Thanks.
0
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Article by: Ivo
C# And Nullable Types Since 2.0 C# has Nullable(T) Generic Structure. The idea behind is to allow value type objects to have null values just like reference types have. This concerns scenarios where not all data sources have values (like a databa…
Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

708 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now