Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Grid view horizontal spacing

Posted on 2007-11-29
7
Medium Priority
?
421 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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
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 2000 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Integration Management Part 2
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Suggested Courses

963 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