Starr Duskk
asked on
Grid view horizontal spacing
I have created an asp.net gridview. I don't want cellspacing and my cellpadding=1. I want to keep the vertical space narrow, but I need more space between columns horizontally. They are too close together.
Is there a way to do that?
thanks!
Is there a way to do that?
thanks!
ASKER
See title. LOL. Sorry, but no, I want gridview horizontal spacing....
>> I need more space between columns horizontally. They are too close together.
>> I need more space between columns horizontally. They are too close together.
ASKER
I ended up creating a padding class:
.gridPadder
{
padding: 0, 5px, 0, 5px;
}
and adding it to each TemplateField that needs padding:
<HeaderStyle CssClass="gridPadder" />
I tried adding it to the gridview Headerstyle, but that didn't work.
My headers are wider than my text, so it works just there. If my item were wider, I'd have to add it there:
<ItemStyle HorizontalAlign="Center" CssClass="gridPadder" />
.gridPadder
{
padding: 0, 5px, 0, 5px;
}
and adding it to each TemplateField that needs padding:
<HeaderStyle CssClass="gridPadder" />
I tried adding it to the gridview Headerstyle, but that didn't work.
My headers are wider than my text, so it works just there. If my item were wider, I'd have to add it there:
<ItemStyle HorizontalAlign="Center" CssClass="gridPadder" />
I get my horizontal/vertical mixed up sometimes...let me test the CssClass route, but you can still force the width:
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False " DataKeyNames="CustomerID"
DataSourceID="SqlDataSourc e1" EmptyDataText="There are no data records to display." AlternatingRowStyle-Height ="50px" RowStyle-Height="50px">
<Columns>
<asp:BoundField DataField="CustomerID" HeaderText="CustomerID" ReadOnly="True" SortExpression="CustomerID " ItemStyle-Width="300px" />
....
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False
DataSourceID="SqlDataSourc
<Columns>
<asp:BoundField DataField="CustomerID" HeaderText="CustomerID" ReadOnly="True" SortExpression="CustomerID
....
ASKER
Well, that's nice to know. But I do want it padded based on the width of the text but a bit wider so the columns don't butt together.
Maybe we crossed paths, but I did find a solution.
If you have a more graceful one that calls for padding in the control to apply throughout that would be great. But looks like there is no such thing.
thanks.
Maybe we crossed paths, but I did find a solution.
If you have a more graceful one that calls for padding in the control to apply throughout that would be great. But looks like there is no such thing.
thanks.
ASKER
sam tran,
btw, did you see my comment on:
https://www.experts-exchange.com/questions/22985466/asp-net-2-0-setting-field-focus.html
I don't know how to "reach" you otherwise I'd sent this private.
thanks.
btw, we have a nascar race track down the road from us too. vroom. argh.
btw, did you see my comment on:
https://www.experts-exchange.com/questions/22985466/asp-net-2-0-setting-field-focus.html
I don't know how to "reach" you otherwise I'd sent this private.
thanks.
btw, we have a nascar race track down the road from us too. vroom. argh.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Open in new window