Solved

Grid view horizontal spacing

Posted on 2007-11-29
7
413 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

 
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

Technology Partners: 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

I have developed many web applications with asp & asp.net and to add and use a dropdownlist was always a very simple task, but with the new asp.net, setting the value is a bit tricky and its not similar to the old traditional method. So in this a…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

631 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