Solved

Grid view horizontal spacing

Posted on 2007-11-29
7
397 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:BobCSD
  • 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 1

Author Comment

by:BobCSD
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 1

Author Comment

by:BobCSD
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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 1

Author Comment

by:BobCSD
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 1

Author Comment

by:BobCSD
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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Lots of people ask this question on how to extend the “MembershipProvider” to make use of custom authentication like using existing database or make use of some other way of authentication. Many blogs show you how to extend the membership provider c…
ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

743 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now