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. Advertising

  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. Advertising

  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. Advertising

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. KathyB
    Replies:
    6
    Views:
    567
    Todd Thompson
    Jun 27, 2003
  2. Paul

    DropDowns... another one.

    Paul, Jul 14, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    379
  3. Bad Starter
    Replies:
    0
    Views:
    344
    Bad Starter
    Jul 18, 2006
  4. Eduardo78
    Replies:
    0
    Views:
    237
    Eduardo78
    Nov 3, 2005
  5. Andrew Tomazos
    Replies:
    2
    Views:
    588
    Nobody
    Dec 12, 2011
Loading...

Share This Page