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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T12:05:55+00:00 2026-05-20T12:05:55+00:00

I have tried all CSS imaginable in Table and paraent controls, and I am

  • 0

I have tried all CSS imaginable in Table and paraent controls, and I am populating and formatting a DropDownList using DataRowView in a DataList Control in .NET 3.5 C#. But I can not for the life of me, CENTER the LIST ITEMS in the Drop Down List.. What would be easiest it seems is use the same formatting procedures I am now using in page behind… here is code.

Trust me Div tags do not work on the List Items.. nor does CSS.

How do I set text-align: Center ??

    if (on == "True")
    {
        DropDownList dl1 = (DropDownList)e.Item.FindControl("ddlOn");
        dl1.BackColor = System.Drawing.Color.LightGreen;
        dl1.ForeColor = System.Drawing.Color.White;
        dl1.Font.Bold = true;
        ListItem li = dl1.Items.FindByValue("True");
        if (li != null)
        {
            li.Selected = true;
        }
    }

Here is DropDownList in ItemTemplate of DataList Control.

                  <tr>
                    <td>
                        <asp:DropDownList ID="ddlOn" runat="server"
                                AutoPostBack="True" Width="100%" CssClass="cen3">
                            <asp:ListItem>True</asp:ListItem>
                            <asp:ListItem>False</asp:ListItem>
                        </asp:DropDownList>
                    </td>
                  </tr>
  • 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-05-20T12:05:56+00:00Added an answer on May 20, 2026 at 12:05 pm

    I am assuming you are trying to center the DropDownList control to the center of the column?

    If so you need to remove Width="100%" from the DropDownList and set the columns text-align to centered.

    <td style="text-align: center">
        <asp:DropDownList ID="ddlOn" runat="server" AutoPostBack="True" CssClass="cen3">
            <asp:ListItem>True</asp:ListItem>
            <asp:ListItem>False</asp:ListItem>
        </asp:DropDownList>
    </td>
    

    EDIT: Based on what I have been able to test, IE (at least up to version 8) does not support setting the text alignment on the select or options tags. I have been able to get it work on Chrome and Firefox by setting it directly in the produced HTML’s select element. The same HTML does nothing in IE.

    I think you might be stuck without the ability to adjust the alignment in IE.

    EDIT: Found this question on SO that comes to the same conclusion:

    .net dropdownlist align text

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

Sidebar

Related Questions

I have tried all the solutions that have been provided including using PRAGMA but
All right so I tried using the button set. So fair, I have been
I have been using this table for a while now and all of a
I have tried almost all the solutions from SO but no success :(. I
i have tried looking online but had no luck, How i could delete all
How can I replace all line-endings in big file (>100MB)? I have tried to
As shown on this page I have tried all I can to make the
I've been looking at the css code for quite a while and have tried
I have tried almost all of the jQuery Modal plugins I can find on
I have tried everything to get this to work on ALL platforms. What am

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.