Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8683861
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T22:09:13+00:00 2026-06-12T22:09:13+00:00

I have a gridview control where I am displaying records from a dataset. The

  • 0

I have a gridview control where I am displaying records from a dataset. The dataset contains records that are space padded as needed. I am trying to follow the solution in this post programatically change style (padding) of a column in ASP.NET GridView

However, when I display them in the gridview, the records show left aligned.

How can I display space padded records?

<asp:GridView runat="server" ID="gvCustomer" Visible="false"
    Width="350px" CellSpacing="1" ClientIDMode="Static" CellPadding="2" 
    AutoGenerateColumns="false" OnRowDataBound="gvCustomer_OnRowDataBound"
    ViewStateMode="Enabled" EmptyDataText="">
        <Columns>
            <asp:BoundField DataField="CustomerName" ControlStyle-Width="225px" HeaderStyle-HorizontalAlign="Center" HeaderText="Customers" />
        </Columns>
</asp:GridView>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T22:09:14+00:00Added an answer on June 12, 2026 at 10:09 pm

    What you’ll have to do is change your BoundField to be a TemplateField, and use a RowDataBound event to replace all spaces with &nbsp;. HTML does not deal with spaces in the way you would like, which is why you’ll need the non-breaking-space (&nbsp;) character.

    Or if you really would like to use a BoundField, modify your sql query to replace spaces with &nbsp; and bind.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a user control that contains a GridView. The GridView has both a
I have a GridView control that I would like to display the rows of
I have a gridview control that has on onclick event bound to every cell.
I have a GridView inside of a User Control populated from a List of
I have a GridView control that for each item has a Hyperlinkfield with a
A typical situation: In my GridView control, I have a Footer row which contains
I have a GridView control on my ASP.NET page that binds to result set
I have a datagrid that is displaying data that is being returned from a
I have a gridview control that i am manually binding the data in. When
I have an ImageButton control as part of a GridView control that is displayed

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.