I am trying to add an item to a dropdown list in a setter, and the added item no longer remains.
I have confirmed that Viewstate has been correctly enabled as suggested in this question ()
Here is my code.
is private sub Page_Init (ByVal as the object, e-e-e. Aventargs as system) handles I.It If ddlcountry.Items.Count & lt; Country.GetList.Length then ddlCountry.DataSource = At this point Country.GetList () ddlCountry.DataBind () ', there are 231 items correctly ddlCountry.' End End Sub Public WriteOnly each country () String Set (ByVal price is nothing as a string) if ddlCountry.Items.FindByValue (Value.Country) then dim Lee as new ListItem (Value.Country , Value.Country) ddlCountry.Items so KInsert (0, l) DdlCountrykSelectedIndex = DdlCountrykItemskIndexOf (Li) or ddlCountry.SelectedValue = Value.Country and "at this point, there are 232 correctly ddlCountry items "that finally set end property Private sub Page_PreRender (ByVal as the object, as ByVal e System.EventArgs) handles Me.PreRender so ddlCountry.Items.FindByText (" & lt; - Please select -> gt; ") Nothing again 'At this point, we are mistaken' is' back for 231 items - this is the problem. 'DdlCountry.Items.Insert (0, New ListItem ( "& lt; - Please select - & gt;", "")) End If End Sub
Did the attribute try to correct the attached items on the dropdown list?
Comments
Post a Comment