Solved

Grid view horizontal spacing

Posted on 2007-11-29
7
404 Views
Last Modified: 2007-11-30
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!
0
Comment
Question by:Starr Duskk
  • 4
  • 3
7 Comments
 
LVL 37

Expert Comment

by:samtran0331
ID: 20374833
basically, you want to set the row height right?
        <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="CustomerID"
            DataSourceID="SqlDataSource1" EmptyDataText="There are no data records to display." AlternatingRowStyle-Height="50px" RowStyle-Height="50px">
....

Open in new window

0
 
LVL 2

Author Comment

by:Starr Duskk
ID: 20374867
See title. LOL. Sorry, but no, I want gridview horizontal spacing....

>> I need more space between columns horizontally. They are too close together.
0
 
LVL 2

Author Comment

by:Starr Duskk
ID: 20375439
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" />
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 37

Expert Comment

by:samtran0331
ID: 20375538
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="SqlDataSource1" 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" />
....
0
 
LVL 2

Author Comment

by:Starr Duskk
ID: 20375679
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.
0
 
LVL 2

Author Comment

by:Starr Duskk
ID: 20375767
sam tran,

btw, did you see  my comment on:
http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/Q_22985466.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.
0
 
LVL 37

Accepted Solution

by:
samtran0331 earned 500 total points
ID: 20381640
>>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.

My current job requires high cross browser compatability, and even with CSS...once it gets too complicated, I end up getting mixed results viewing on IE vs. FF vs. Opera vs. Safari

As far as I know, you're right, with gridviews there is no such thing that is "graceful".
It's the opposite of graceful, brute force...I've had really picky clients and usually what I end up doing is not padding the gridview, but padding the data.
either in the itemdatabound: e.item.dataitem("somefield").tostring.padright(5," ")
or in the aspx or even in the sql

>>I don't know how to "reach" you otherwise I'd sent this private.
If it's relevant to the question, the best place is to leave it in the question, it might help someone in the future.
But if you feel it's something that needs to be private, use my EE email, it's my username @ the EE domain

>>we have a nascar race track down the road from us too.
I've heard the only interview question for nascar is:
"Can you go straight and turn left?"
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

792 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question