I know that if the width isn't set, the DropDownList will be the size of the largest item. Is there a way to have it a set size, but be the auto width for the elements when it opens?
I don't believe so. You can set the Width property (DropDownList.Width) to any valid setting ("50 px", "35%", etc.) but I think the largest item will override the width setting. I haven't tested this, but it's what I suspect. Good luck.
When I tried Width="50px" it just cut everything else off, which doesn't matter a lot to me when it is closed because I don't have a lot of space, but I need to see more when selecting from the drop down.
mdenn
Participant
1854 Points
454 Posts
Dynamic DropDownList Width
Sep 07, 2006 01:28 PM|LINK
ScottDarth
Member
66 Points
50 Posts
Re: Dynamic DropDownList Width
Sep 07, 2006 03:53 PM|LINK
mdenn
Participant
1854 Points
454 Posts
Re: Dynamic DropDownList Width
Sep 07, 2006 04:16 PM|LINK
azizi021@hot...
Member
96 Points
24 Posts
Re: Dynamic DropDownList Width
Nov 09, 2012 12:10 PM|LINK
.ddlclass
{
background:#f7f6f6;
width:100%;
padding:0px;
margin:0px;
}
DropDownList _Drop = new System.Web.UI.WebControls.DropDownList();
_Drop.CssClass = "ddlclass";
_Drop.ID = "XXXXX";
_Drop.DataSource = DataTable;
_Drop.DataBind();
_Drop.Items.Insert(0, "Select Item");
enjoy asp.net :)
BizTalk & SharePoint Developer