ASP.Net Datagrid Row Height

RichW
RichW used Ask the Experts™
on
Hi All

I am using ASP.NET 1.0 with VB codebehind.

How do I do a tablestyles for a datagrid control?  I want to shrink the row height of the datagrid rows, and I cannot find anything out there for tablestyles for ASP.Net.

Any help would be appreciated.

Thanks

RichW
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
you can assign css to datagrid.
If you check the view source of datagrid after rendering on browser, it gets converted into table structure. so css you made will be automatically applied to datagrid.

Hope this solves your problem.
Robb HillSenior .Net Full Stack Developer

Commented:
Read this link..it even gives you examples of styles when using this verson of asp.net...
A css is preferred but this example will show you how to hard code it in the control


http://www.maconstateit.net/tutorials/ASPNET1/default.htm

Robb HillSenior .Net Full Stack Developer

Commented:
Here is a snippet
<asp:DataGrid id="ProductGrid" runat="server"
  AutoGenerateColumns="False"
  CellPadding="1"
  GridLines="Horizontal"
  BorderWidth="3"
  BackColor="#F0F0F0"
  ForeColor="#990000"
  ShowFooter="True"
    HeaderStyle-BackColor="#707070"
    HeaderStyle-ForeColor="#FFFFFF"
    HeaderStyle-Font-Bold="True"
    HeaderStyle-HorizontalAlign="Center"
    AlternatingItemStyle-ForeColor="#FFFFFF"
    AlternatingItemStyle-BackColor="#990000"
    FooterStyle-BackColor="#707070"
    FooterStyle-ForeColor="#FFFFFF"
    FooterStyle-HorizontalAlign="Right" 
    FooterStyle-Font-Italic="True"
  >
  <Columns>
    <asp:BoundColumn
      DataField="ItemName"
      HeaderText="Product Name"
      />
    <asp:BoundColumn
      DataField="ItemPrice"
      HeaderText="Product Price*"
      ItemStyle-HorizontalAlign="Right"
      FooterText="*Average Street Price"
      FooterStyle-Font-Size="7pt"
      />
  </Columns>

</asp:DataGrid>

Open in new window

Author

Commented:
robbhill, the link doesn't point to any particular article on the subject, and I can't see in the code you posted where it sets the height of the rows of the datagrid.  Sorry if I'm missing it, but I just don't see it.

RichW

Author

Commented:
Added line-height: 9px; to css file and it worked.

Thanks!

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial