DropDownList AppendDataBoundItems(第一项为空白且无重复项)
问题描述
I have a DropDownList
inside an UpdatePanel
that is populated on postback from a SqlDataSource
. It has a parameter which is another control. I sometimes need multiple postbacks, but what happens is that each time the update panel refreshes, items are added to the DropDownList
. So the DropDownList
ends up having data that is incorrect, or repeated data.
I have the AppendDataBoundItems
property set to true
because I need the first item to be blank.
How can I overcome this problem? Is there another way to have a blank first item?
(This DropDownList
is in an ASP.NET 2.0 web app, and codebehind is in C#)
Instead of using AppendDataboundItems='true'
(which will cause the problem you are talking about), respond to the DataBound
event for the DropDownList
and then add your "blank" item to the top of the list.
Then in your code behind:
这篇关于DropDownList AppendDataBoundItems(第一项为空白且无重复项)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!