开发者

ListBox Item increase when postback

I made a web part use ASP.NET. There are a listbox开发者_如何学C and two buttons on it. When you click the Button A, it would add a new item into the listbox.When clicking the Button B, it would postback the list items data. But when you click the button B, the number of listbox number becomes twice. Does anyone meet this problem before?

Best Regards,


Are you adding items to the list box in your load method? You need to check if it's a Postback before adding items again:

protected void Page_Load(object sender, EventArgs e)
{
    if (!this.IsPostBack)
    {
        // fill list box
    }
}


can you post some code samples on what is done in the post back?

just a guess - are you checking the IsPostBack flag before initalizing data related to this list box?

without seeing/understanding what you do on the post it's hard to help...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜