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>
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>
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>
<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>
ASKER
I tried <RowStyle Height="20px" Wrap="false" /> , it's not working. Any other ways?
ASKER
I just tried <RowStyle CssClass="gridstyle" />, it's still not working. Any other way? Thanks.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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.
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
ASKER
I'll post the answer.
ASKER
THanks for the comment
<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>