Click here to Skip to main content
15,897,273 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello all,

Am using GridView in my application in which I use to bound datatable to the GriedView.But the problem is that i need to reduce the row height of GridView.
i google that thing a lot.Tried each an every solution but still the rowhieght remains the same.The things that i had tried are as follows.

1.
HTML
<rowstyle backcolor="#F7F6F3" forecolor="#333333" horizontalalign="Left" Height="5px" 
  Font-Size="Medium"        />

2.
HTML
<emptydatarowstyle height="5px" />

3.
HTML
<alternatingrowstyle backcolor="White" forecolor="#284775" height="10px" />

4.
HTML
<editrowstyle backcolor="#999999" height="5%" />

Still the height of cells or row remain the same i.e. as it is.

So can anybody help me to tackle the problem.


Thanks in Advance
Yogesh
Posted
Updated 8-Jan-12 1:04am
v3

try as
C#
<asp:boundfield datafield="Status" headertext="Status" xmlns:asp="#unknown">
                                    SortExpression="Status" HtmlEncode="False" ControlStyle-Width="100px" 
                                    ItemStyle-Width="200px" HeaderStyle-Height="15px">
                                  <controlstyle width="100px" />
                                    <HeaderStyle Height="15px" />
                                    <itemstyle width="200px" />
 <itemstyle width="100px" />
                                     </asp:boundfield>
 
Share this answer
 
Comments
YOGESH DHAGE 6-Jan-12 3:09am    
I just use that code snipest under GridView
i.e <asp:GridView>
<asp:boundfield datafield="Status" headertext="Status"
xmlns:asp="#unknown">
SortExpression="Status" HtmlEncode="False" ControlStyle-Width="100px"
ItemStyle-Width="200px" HeaderStyle-Height="15px">
<controlstyle width="100px">
<HeaderStyle Height="15px" />
<itemstyle width="200px">
<itemstyle width="100px">




It gives me error on tag <asp:boundfield> the error is:
The element is not supported
uspatel 6-Jan-12 4:20am    
how you are binding your gridview. can you share code?
Hi,

I think there is no such customization of height in GridView.
You may customize the style of grid in your intire solution by doing
these example:

In your Client page:
XML
Theme="GridSkin" EnableTheming="true"



<head id="Head1" runat="server">
    <title>Untitled Page</title>
    <link rel="stylesheet" type="text/css" href="Css/GridControlStyle.css" />
</head>

<!-- Some code here -->

<asp:GridView AutoGenerateColumns="False" ID="grdAuditTrail" runat="server"
   SkinID="skinGridView" EmptyDataText="No record.">
   <EmptyDataRowStyle ForeColor="White" />

   <!-- Some code here -->

</asp:GridView>



In your Css/GridControlStyle.css
Code inside:

C#
.clsGridHdrSub
{
	background-color: #067ef9;
	color: White;
	font-weight: lighter;
	font-family: Verdana;
	font-size: xx-small;
	border: 0;
	text-align: justify;
}
.clsGridEmptyRow
{
	background-color: #067ef9;
	color: White;
	font-weight: 50;
	font-family: Candara;
	font-size: medium;
	border: 0;
}
.clsGridAlternate
{
	color:#031999;
	font-family:Verdana;
	font-weight:lighter;
	font-size:xx-small;
	background-color:#F0F8FF;
	
}
.clsGridAlternate:hover
{
	color:Teal;
	font-family:Verdana;
	font-weight:lighter;
	font-size:xx-small;	
	background-color: White;
	background-color:#daeeff;
}
.clsGridRow
{
	background-color:White;
	color:#031999;
	font-family:Verdana;
	font-weight:lighter;
	font-size:xx-small;
}
.clsGridRow:hover
{	
	color:#031999;
	color:Teal;		
	font-family:Verdana;
	font-weight:lighter;
	font-size:xx-small;	
	background-color: White;
	background-color:#F0F8FF;
	background-color:#daeeff;
}
.clsGridHdr
{
	color:#0453A2;
	color:White;
	font-weight:bold;
	font-family:Verdana;
	font-size:x-small;	
	background-repeat: repeat-x;
	height: 12px;
	padding: 1px 3px 1px 3px;
	border: solid 2px Black;
	font-variant:small-caps;
	background-color:#067ef9;
	background-image: url('../Images/gridheader.gif');
	background-repeat:repeat-x;
	text-decoration: none;		
}
.clsGridFtr
{
	color:#0453A2;
	font-weight:bold;
	font-family:Verdana;
	font-size:x-small;	
	background-repeat: repeat-x;
	height: 10px;
	padding: 1px 3px 1px 3px;
	font-variant:small-caps;
	text-decoration:underline;
	background-color:#f5faff;	
}
.clsGridPager
{
	color:#067ef9;
	font-weight:normal;
	font-family: Verdana;
	font-size:x-small;
	border:0;
	text-align:justify;
}




In your App_Themes/GridSkin.skin
Code inside:
C#
<asp:gridview borderwidth="1" bordercolor="White" pagesize="10" allowpaging="True" width="100%" cellpadding="5" xmlns:asp="#unknown">
    runat="server" AutoGenerateColumns="false" 
    skinID="skinGridView">
    <rowstyle cssclass="clsGridRow" horizontalalign="Left" />
    <emptydatarowstyle cssclass="clsGridEmptyRow" />
    <pagerstyle horizontalalign="Center" cssclass="clsGridPager" />
    <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
    <HeaderStyle CssClass="clsGridHdr" ForeColor="White" />
    <footerstyle cssclass="clsGridFtr" />
    <editrowstyle backcolor="#D1DDF1" />
    <alternatingrowstyle cssclass="clsGridAlternate" />
</asp:gridview>


Hope this could help...

Do not forget to vote if could help so that others may consider as an answer.

Regards,
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900