Dropdowns move text to center

Discussion in 'ASP .Net' started by tshad, Sep 28, 2009.

  1. tshad

    tshad Guest

    I have dropdowns that I am filling then adding a line " --All--" to the
    first item.

    I am trying to get it closer to the center (would be nice to be able to
    center it).

    public void GetClientNames()

    {

    SqlCommand dbCommand;

    dbCommand = new SqlCommand("GetClientName",

    new
    SqlConnection(ConfigurationManager.ConnectionStrings["ConnectString"].ConnectionString));

    dbCommand.CommandType = CommandType.StoredProcedure;

    dbCommand.Connection.Open();

    ddlClient.DataSource =
    dbCommand.ExecuteReader(CommandBehavior.CloseConnection);

    ddlClient.DataTextField = "ClientName";

    ddlClient.DataValueField = "ClientId";

    ddlClient.DataBind();

    ddlClient.Items.Insert(0, " --All--");

    }

    Why does it still move "--All--" to the left? I assume it takes out leading
    blanks.

    Is there a way (other then putting in a whole bunch of " " in front of
    them) to move the text a little to the right or center it? Only the first
    item not all the items.

    Thanks,

    Tom
     
    tshad, Sep 28, 2009
    #1
    1. Advertisements

  2. On Sep 28, 7:42 pm, "tshad" <> wrote:
    > I have dropdowns that I am filling then adding a line "      --All--" to the
    > first item.
    >
    > I am trying to get it closer to the center (would be nice to be able to
    > center it).
    >
    > public void GetClientNames()
    >
    > {
    >
    > SqlCommand dbCommand;
    >
    > dbCommand = new SqlCommand("GetClientName",
    >
    > new
    > SqlConnection(ConfigurationManager.ConnectionStrings["ConnectString"].Conne­ctionString));
    >
    > dbCommand.CommandType = CommandType.StoredProcedure;
    >
    > dbCommand.Connection.Open();
    >
    > ddlClient.DataSource =
    > dbCommand.ExecuteReader(CommandBehavior.CloseConnection);
    >
    > ddlClient.DataTextField = "ClientName";
    >
    > ddlClient.DataValueField = "ClientId";
    >
    > ddlClient.DataBind();
    >
    > ddlClient.Items.Insert(0, "           --All--");
    >
    > }
    >
    > Why does it still move "--All--" to the left?  I assume it takes out leading
    > blanks.
    >
    > Is there a way (other then putting in a whole bunch of "&nbsp;" in front of
    > them) to move the text a little to the right or center it?  Only the first
    > item not all the items.
    >
    > Thanks,
    >
    > Tom


    No.
     
    Alexey Smirnov, Sep 29, 2009
    #2
    1. Advertisements

  3. tshad

    tshad Guest

    "Mark Rae [MVP]" <> wrote in message
    news:...
    > "tshad" <> wrote in message
    > news:...
    >
    >> Why does it still move "--All--" to the left?

    >
    > Because browsers ignore multiple spaces.
    >
    >
    >> Is there a way (other then putting in a whole bunch of "&nbsp;" in front
    >> of them) to move the text a little to the right or center it? Only the
    >> first item not all the items.

    >
    > No.
    >

    I didn't think so.

    I thought there mignt have been a way to put a style on one item but wasn't
    sure.

    Thanks,

    Tom

    >
    > --
    > Mark Rae
    > ASP.NET MVP
    > http://www.markrae.net
     
    tshad, Sep 29, 2009
    #3
  4. tshad

    tshad Guest

    "Mark Rae [MVP]" <> wrote in message
    news:%...
    > "tshad" <> wrote in message
    > news:%...
    >
    >> I thought there mignt have been a way to put a style on one item but
    >> wasn't sure.

    >
    >
    > You can certainly do that, e.g.
    >
    > <asp:ListItem style="text-align:center;">A</asp:ListItem>
    > <asp:ListItem
    > style="color:Blue;">Antidisestablishmentarianism</asp:ListItem>
    >
    > The colour style will work but the text alignment style will simply be
    > ignored because it's not part of the DOM for list items...
    >
    > Also, the above markup will be flagged as invalid depending on which
    > DOCTYPE validation you're using...
    >

    So I guess it's &nbsp for me.

    Thanks,

    Tom
    >
    > --
    > Mark Rae
    > ASP.NET MVP
    > http://www.markrae.net
     
    tshad, Sep 29, 2009
    #4
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. kpg

    Center text in a label

    kpg, Oct 7, 2005, in forum: ASP .Net
    Replies:
    3
    Views:
    9,002
    Frankie
    Oct 7, 2005
  2. Beck
    Replies:
    3
    Views:
    1,032
    David Dorward
    Nov 11, 2005
  3. Replies:
    17
    Views:
    1,825
    acorn
    Dec 1, 2005
  4. Bad Starter
    Replies:
    0
    Views:
    434
    Bad Starter
    Jul 18, 2006
  5. richard

    how to center text in css ?

    richard, Sep 22, 2006, in forum: HTML
    Replies:
    5
    Views:
    559
    Jonathan N. Little
    Sep 22, 2006
  6. Replies:
    1
    Views:
    485
    Jukka K. Korpela
    Jan 31, 2007
  7. Eduardo78
    Replies:
    0
    Views:
    439
    Eduardo78
    Nov 3, 2005
  8. Andrew Tomazos
    Replies:
    2
    Views:
    941
    Nobody
    Dec 12, 2011
Loading...