I have the following webDropDown inside an update panel:
//Sets the selected value as the text, rather than the selected text function webDropDown_SelectionChanging(sender, e) { e.get_value()[0].set_text(e.get_value()[0].get_value()); }
On page load:
With departments .SQL = "SELECT DI.DEPARTMENT DEPT, DI.DEPARTMENT_DESC DESCR FROM COMMISH.DEPARTMENT_INFO DI WHERE DI.ACTIVE_FLAG = 'Y' ORDER BY DEPARTMENT_NUMBER" If .Select_Records_Custom_SQL(dtData) Then Me.wddDepartment.DataSource = dtData Me.wddDepartment.ValueField = "DEPT" Me.wddDepartment.TextField = "DESCR" Me.wddDepartment.DataBind() Me.wddDepartment.NullText = " " 'uwcDepartment.DataSource = dtData 'uwcDepartment.DataBind() End If End With
When user clicks search:
wddDepartment.CurrentValue = CStr(.Order_Department)
Everything works like I want it to, with one exception. When the user clicks search and the dropdown list value is updated, the dropdown width ignores its 50px width setting and is set to some default value. First question obviously is why does it do this? And second, how do I get it to remain at the 50px setting?
Edit: If I remove the page_load function where I populate the dropdown list, the width does not change.
Hello,
There are actually two different setting for the WebDropDown Width. The first one is managing the WDD's input width itself and the second one is managing the width of the container for the WDD Items.Width="50px"DropDownContainerWidth="400px" Both could differ and yet I suggest keeping these the same for better user experience. By default, if you would like to set the containerWidth to be wide enough to match the width of the longest items inside, you could use empty string for it like:DropDownContainerWidth=""I am attaching a runnable code sample illustrating this. Both widths are set via the Markup.
Please let me know if you require further assistance. In such case, please feel free to modify my sample with your approach, so I could take a look at the actual code in use.
I do have DropDownContainerWidth set, and I cannot have them both the same. I need width to be smaller than the DropDownContainerWidth. When the user clicks search and the dropdowns are updated, they do not go to the DropDownContainerWidth setting - apparently there is some default setting, and the dropdowns change to that size.
It should be simple to see this. Set up a dropdown that gets populated by a datasource on page load. Then set up a button to set the dropdown to a string when the button is clicked. Here is the simplest example I can give from my project:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
drConfirm = dtConfirm.NewRow() drConfirm("value") = "Y" drConfirm("key") = "Yes" dtConfirm.Rows.Add(drConfirm)
drConfirm = dtConfirm.NewRow() drConfirm("value") = "N" drConfirm("key") = "No" dtConfirm.Rows.Add(drConfirm)
Me.wddConfirm.DataSource = dtConfirm Me.wddConfirm.TextField = "key" Me.wddConfirm.ValueField = "value" Me.wddConfirm.DataBind() Me.wddConfirm.NullText = "N"
Protected Sub ibtnSearch_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles ibtnSearch.Click
wddConfirm.CurrentValue = "N"
End Sub