M
Milsnips
hi there,
i have the following HTML code:
--------------------------
<aspropDownList id="hddList" runat="server">
<asp:ListItem Value="1">Item 1</asp:ListItem>
<asp:ListItem Value="2">Item 2</asp:ListItem>
<asp:ListItem Value="3">Item 3</asp:ListItem>
<asp:ListItem Value="4">Item 4</asp:ListItem>
<asp:ListItem Value="5">Item 5</asp:ListItem>
<asp:ListItem Value="6">Item </asp:ListItem>
</aspropDownList>
--------------------------
and the following VB.NET code behind:
----------------------------------
Private Sub hddList_PreRender(ByVal sender As Object, ByVal e As
System.EventArgs) Handles hddList.PreRender
If hddList.Items.Count > 0 Then
If Request.QueryString("type") <> "" Then
For Each i As ListItem In hddList.Items
If i.Value <> Request.QueryString("type") Then
'remove item not to be shown
hddList.Items.Remove(i.Text)
End If
Next
End If
End If
End Sub
----------------------------------
What i am doing is if querystring value = , say 3, i want to programatically
remove all items and only leave Value=3 in there but i am getting an error:
Exception Details: System.InvalidOperationException: Collection was
modified; enumeration operation may not execute.
please help,
Paul
i have the following HTML code:
--------------------------
<aspropDownList id="hddList" runat="server">
<asp:ListItem Value="1">Item 1</asp:ListItem>
<asp:ListItem Value="2">Item 2</asp:ListItem>
<asp:ListItem Value="3">Item 3</asp:ListItem>
<asp:ListItem Value="4">Item 4</asp:ListItem>
<asp:ListItem Value="5">Item 5</asp:ListItem>
<asp:ListItem Value="6">Item </asp:ListItem>
</aspropDownList>
--------------------------
and the following VB.NET code behind:
----------------------------------
Private Sub hddList_PreRender(ByVal sender As Object, ByVal e As
System.EventArgs) Handles hddList.PreRender
If hddList.Items.Count > 0 Then
If Request.QueryString("type") <> "" Then
For Each i As ListItem In hddList.Items
If i.Value <> Request.QueryString("type") Then
'remove item not to be shown
hddList.Items.Remove(i.Text)
End If
Next
End If
End If
End Sub
----------------------------------
What i am doing is if querystring value = , say 3, i want to programatically
remove all items and only leave Value=3 in there but i am getting an error:
Exception Details: System.InvalidOperationException: Collection was
modified; enumeration operation may not execute.
please help,
Paul