Dropdowns move text to center

  • Thread starter Thread starter tshad
  • Start date Start date
T

tshad

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
 
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 " " 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.
 
Mark Rae said:
Because browsers ignore multiple spaces.



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 said:
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
 
Back
Top