Solved

Grid view horizontal spacing

Posted on 2007-11-29
7
410 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
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!

 
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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
disable data migrations in visual studio 2017 4 68
Record locking on classic ASP 3 64
What are MicroServices? 4 68
What is GIS method of Geometry data type? 6 36
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
Suggested Courses

738 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