Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I add rounded corners to a GridView table in my .net code?

I've tried adding webkit border radius / moz border radius / border radius to both the css definition and the .net definition, but to no avail. Help!

<tr>
    <td width="60%" align="center">
        <asp:GridView ID="GridView_VE" runat="server" CssClass="table1" HorizontalAlign="Center" Width="80%"   
        OnPageIndexChanging="GridView_VE_PageIndexChanging" Font-Names="Century Gothic" Font-Size="Large" Height="100%"
        AllowPaging="True" PageSize="4" RowStyle-Height="30px" -webkit-border-radius= "10px" -moz-border-radius="10px"
        border-radius="10px" border="2px" border-color="Black">
            <Columns>
            ...
            </Columns>
            <PagerStyle Height="20px" />
            <RowStyle Wrap="True" />
         </asp:GridView>
    </td>
</tr>

I've tried implementing the corners to the td , tr and table too. But again, fail.

like image 794
Shalapolia Avatar asked Jan 14 '23 11:01

Shalapolia


2 Answers

Wrap the <asp:GridView> in a div and then place the rounded corners on that div.

<div class="rounded-corners">
    <asp:GridView>....</asp:GridView>
</div>

And the CSS

.rounded-corners {
  border: 1px solid black;
  -webkit-border-radius: 8px;
  -moz-border-radius: 8px;
  border-radius: 8px;
  overflow: hidden;
}
like image 147
Justin Avatar answered Jan 17 '23 01:01

Justin


You should wrap your style elements inside a style="" element. Like so: <table style="border-radius: 8px; -moz-border-radius: 8px; -webkit-border-radius: 8px;">

BUT it might be better to only set border-radius on the first and last row.

Anyway, here are a couple of options: http://jsfiddle.net/wMGnq/

Oh, and also make sure that border-collapse is not set to collapse! See: https://developer.mozilla.org/en/CSS/border-radius

like image 38
Bram Vanroy Avatar answered Jan 17 '23 00:01

Bram Vanroy