Setting values to a UserControl
-
I have created a usercontrol having a dropdownlist together with other functionality. I need to set the selectedindex of the dropdown from the values saved in the database. Although the value is passing successfully to the set value, however am not seeing the values shown in the dropdownlist. Any ideas? Following is a snippet of my code; Private _selRequest As Integer Public Property RequestValue() As Integer Get Return _selRequest End Get Set(ByVal Value As Integer) _selRequest = Value Me.drpPersons.SelectedIndex = _selRequest End Set End Property
-
I have created a usercontrol having a dropdownlist together with other functionality. I need to set the selectedindex of the dropdown from the values saved in the database. Although the value is passing successfully to the set value, however am not seeing the values shown in the dropdownlist. Any ideas? Following is a snippet of my code; Private _selRequest As Integer Public Property RequestValue() As Integer Get Return _selRequest End Get Set(ByVal Value As Integer) _selRequest = Value Me.drpPersons.SelectedIndex = _selRequest End Set End Property
Hi, try checking the page load event of your page that is using this control. see if u have if(!IspostBack) in your page load. or try to add a public function to set the dropdown in the control.(set property should would be same but still u can give a try) Regards, Anil :)