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,
I am glad you found the cause of this. I suggest you to use the latest available Service Release for the product, as this seems to be not reproducible with the latest one available.
I think I found what is causing it. For some reason I left out one piece of code that is causing this:
Me.wddDeliverTo.NullText = " "
or in HTML:
NullText=" "
If either of these are set, the strange behavior happens. If I don't have this, then it will show a selected value even if nothing is set.
Thank you for the additional code snippet. However, I could still not reproduce the wrong behavior you are describing. I have searched via our internal system and could not find any similar issues to be reported. I have modified the sample to match yours and it works as expected. I suggest you test it on your side and see the behavior for yourself. Additionally, what is the exact product version you are using?
Here is a somewhat working example, although I am using VB, not C#, so there will probably be a couple changes for you to make to get it to work.
Hello Jesse,
In order to further investigate this issue, it will be best if you modify the attached file or create a new one illustrating the approach. This will speed up the process of investigating the matter and reproducing the issue, as I could debug the actual code in use.