E
Erik
Hi Everyone,
I'm not sure why this is happening but I need to populate a listbox with
about 10000 items and then at some point clear them again. Adding the items
is not a problem and it takes 2 or 3 seconds but when I try and clear them
it just hangs the browser at 100% cpu. The code I am testing with is below.
I have tried clearing the listbox client side as well and it is exactly the
same problem.
Any help would be appreciated
Thanks
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="test.aspx.cs"
Inherits="test" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
protected void btnShowOrderDetails_Click(object sender, EventArgs e)
{
for (int i = 0; i < 10000; i++)
{
lst.Items.Add(new ListItem(i + " Testing Testing Testing",
i.ToString()));
}
}
protected void btnClearOrderDetails_Click(object sender, EventArgs e)
{
lst.Items.Clear();
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server" />
</div>
<div>
<asp:Button ID="btnShowOrderDetails" runat="server"
OnClick="btnShowOrderDetails_Click" Text="Show Order Details" />
<br />
<asp:Button ID="btnClearOrderDetails" runat="server" Text="Clear
Order Details" OnClick="btnClearOrderDetails_Click" /><br />
<br />
<asp:UpdatePanel ID="UpdatePanel2" runat="server"
ChildrenAsTriggers="false" UpdateMode="conditional" EnableViewState="false">
<Triggers>
<asp:AsyncPostBackTrigger
ControlID="btnShowOrderDetails" EventName="Click" />
<asp:AsyncPostBackTrigger
ControlID="btnClearOrderDetails" EventName="Click" />
</Triggers>
<ContentTemplate>
<asp:ListBox id="lst" runat="server" Style="width:
300px; height: 100px;" EnableViewState="false" Rows="10"
SelectionMode="Multiple"></asp:ListBox>
</ContentTemplate>
</asp:UpdatePanel>
</div>
</form>
</body>
</html>
I'm not sure why this is happening but I need to populate a listbox with
about 10000 items and then at some point clear them again. Adding the items
is not a problem and it takes 2 or 3 seconds but when I try and clear them
it just hangs the browser at 100% cpu. The code I am testing with is below.
I have tried clearing the listbox client side as well and it is exactly the
same problem.
Any help would be appreciated
Thanks
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="test.aspx.cs"
Inherits="test" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
protected void btnShowOrderDetails_Click(object sender, EventArgs e)
{
for (int i = 0; i < 10000; i++)
{
lst.Items.Add(new ListItem(i + " Testing Testing Testing",
i.ToString()));
}
}
protected void btnClearOrderDetails_Click(object sender, EventArgs e)
{
lst.Items.Clear();
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server" />
</div>
<div>
<asp:Button ID="btnShowOrderDetails" runat="server"
OnClick="btnShowOrderDetails_Click" Text="Show Order Details" />
<br />
<asp:Button ID="btnClearOrderDetails" runat="server" Text="Clear
Order Details" OnClick="btnClearOrderDetails_Click" /><br />
<br />
<asp:UpdatePanel ID="UpdatePanel2" runat="server"
ChildrenAsTriggers="false" UpdateMode="conditional" EnableViewState="false">
<Triggers>
<asp:AsyncPostBackTrigger
ControlID="btnShowOrderDetails" EventName="Click" />
<asp:AsyncPostBackTrigger
ControlID="btnClearOrderDetails" EventName="Click" />
</Triggers>
<ContentTemplate>
<asp:ListBox id="lst" runat="server" Style="width:
300px; height: 100px;" EnableViewState="false" Rows="10"
SelectionMode="Multiple"></asp:ListBox>
</ContentTemplate>
</asp:UpdatePanel>
</div>
</form>
</body>
</html>