Dropdownlist items keep duplicating [modified]
-
I have a dropdownlist whose items are populated dynamically on a button click. I have a gridview being populated with values depending on the value selected in the dropdown list. The problem is that each time the SelectedIndexChanged event is fired the items in the drop down list are duplicated. I cannot use a if(!Page.Postback) block around the dynamic creation of the dropdown's list of items because that occurs on a button click so the page needs to be posted back the first time otherwise the items won't populate. Also, once it duplicates the items if I click on any of the items in the list ... the dropdownlist completely disappears from the page. Any ideas on what I should do ?
modified on Thursday, October 16, 2008 5:54 PM
-
I have a dropdownlist whose items are populated dynamically on a button click. I have a gridview being populated with values depending on the value selected in the dropdown list. The problem is that each time the SelectedIndexChanged event is fired the items in the drop down list are duplicated. I cannot use a if(!Page.Postback) block around the dynamic creation of the dropdown's list of items because that occurs on a button click so the page needs to be posted back the first time otherwise the items won't populate. Also, once it duplicates the items if I click on any of the items in the list ... the dropdownlist completely disappears from the page. Any ideas on what I should do ?
modified on Thursday, October 16, 2008 5:54 PM
can you test if your dropdownlist has items before adding new items? otherwise skip adding... other than that, if AutoPostback of the dropdownlist is set to false, it wont refresh the page
Intelligence is almost useless for those who have nothing else! Email: caiokf@gmail.com
-
I have a dropdownlist whose items are populated dynamically on a button click. I have a gridview being populated with values depending on the value selected in the dropdown list. The problem is that each time the SelectedIndexChanged event is fired the items in the drop down list are duplicated. I cannot use a if(!Page.Postback) block around the dynamic creation of the dropdown's list of items because that occurs on a button click so the page needs to be posted back the first time otherwise the items won't populate. Also, once it duplicates the items if I click on any of the items in the list ... the dropdownlist completely disappears from the page. Any ideas on what I should do ?
modified on Thursday, October 16, 2008 5:54 PM
Cyberpulse wrote:
I cannot use a if(!Page.Postback) block around the dynamic creation of the dropdown's list of items because that occurs on a button click so the page needs to be posted back the first time otherwise the items won't populate.
Clear the DropDownList Items everytime using MyDropDown.Items.Clear()
Castle Rider
What if I freeze??? Don't forget to breath...
My: Website | Yahoo Group | Blog Spot