B
Blasting Cap
I have some code where I populate some items in a listbox. The code is:
ListBoxDomesticExport.Items.Insert(0, "Domestic (Commercial)")
ListBoxDomesticExport.Items(0).Value = "0"
ListBoxDomesticExport.Items.Insert(1, "Domestic (All)")
ListBoxDomesticExport.Items(1).Value = "1"
ListBoxDomesticExport.Items.Insert(2, "Domestic (Non Commercial)")
ListBoxDomesticExport.Items(2).Value = "2"
ListBoxDomesticExport.Items.Insert(3, "Export")
ListBoxDomesticExport.Items(3).Value = "3"
ListBoxDomesticExport.Rows = 4
This works fine.
However, it populates the listbox 2 times, with the same data.
I only call the routine in 2 places. One is in the page_load event, below.
If Not Page.IsPostBack Then
setDomExport()
End If
The other is in a button click event, for a reset button.
Private Sub btnReset_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnReset.Click
setDomExport()
End Sub
Basically, in both places, I set other listboxes I have on that same
page, and set some indexes to -1.
When I run the page though, the routine SetDomExport() gets run twice,
no matter what.
Why is this doing this? Is there a way to make it NOT run it twice, or
is there a way to keep it from adding the same elements to the listbox a
second time?
Any help appreciated.
BC
ListBoxDomesticExport.Items.Insert(0, "Domestic (Commercial)")
ListBoxDomesticExport.Items(0).Value = "0"
ListBoxDomesticExport.Items.Insert(1, "Domestic (All)")
ListBoxDomesticExport.Items(1).Value = "1"
ListBoxDomesticExport.Items.Insert(2, "Domestic (Non Commercial)")
ListBoxDomesticExport.Items(2).Value = "2"
ListBoxDomesticExport.Items.Insert(3, "Export")
ListBoxDomesticExport.Items(3).Value = "3"
ListBoxDomesticExport.Rows = 4
This works fine.
However, it populates the listbox 2 times, with the same data.
I only call the routine in 2 places. One is in the page_load event, below.
If Not Page.IsPostBack Then
setDomExport()
End If
The other is in a button click event, for a reset button.
Private Sub btnReset_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnReset.Click
setDomExport()
End Sub
Basically, in both places, I set other listboxes I have on that same
page, and set some indexes to -1.
When I run the page though, the routine SetDomExport() gets run twice,
no matter what.
Why is this doing this? Is there a way to make it NOT run it twice, or
is there a way to keep it from adding the same elements to the listbox a
second time?
Any help appreciated.
BC