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 9218059
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T02:46:32+00:00 2026-06-18T02:46:32+00:00

I am using an ASP Data Grid I am Binding the data field,Header Text

  • 0

I am using an ASP Data Grid I am Binding the data field,Header Text dynamically through code behind(c#).

I am also setting the style of the column dynamically all are working fine but one of the Column Horizontal-align.Center is not working .

I have checked if the style is getting overridden but it is not…

This the block of code giving an issue:

        BoundField field4 = new BoundField();
        field4.DataField = dtdata.Tables[0].Columns["data"].ToString();
        field4.HeaderText = "Percentage%";
        field4.DataFormatString = "{0:N1}%";
        field4.SortExpression = "data";
        field4.ItemStyle.HorizontalAlign = HorizontalAlign.Center;
        grdMarginGrid.Columns.Add(field4);

Can anyone help me in recognising where the issue is..

Thanks in advance,
Divya.

  • 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-18T02:46:33+00:00Added an answer on June 18, 2026 at 2:46 am

    I think your other styles overriding your new styles.

    You can do something like this

    Try adding a CSS class to your gridview from your ASPX code, and assign following styles to your class.

     <asp:GridView CssClass="grid" runat="server">
        <!-- your options -->
     </asp:GridView>
    
    .grid td, .grid th{
      text-align:center;
    }
    

    You can add CSS class from code behind also..
    MSDN LINK

    This will set all your columns text to center in your gridview

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

Sidebar

Related Questions

In web application[asp.net], i am using telerik grid control, i am bind the data
I am using ASP.MVC and jqgrid 3.7.2. The data loads OK into the grid
I'm using radgrid in my asp.net application. In button click i'm binding the grid
I'm using Grid view in my asp.net page and I'm fetching data from SQL
I am using a asp.net grid view to load data from my sql data
I have a repeater that's bound to a SQL Data Source (using ASP.NET). Are
I have a lot of data-entryists using my ASP.NET application and we have all
I have an ASP.NET Dynamic Data application (using Entity Framework) in which I have
I'm using Elmah with ASP.NET and wondering how I would add custom data, such
I'm trying to make a login page using html, ajax & ASP.NET.The data is

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.