My web page has 3 list boxes a 4 buttons. Let me present some code first:
Listbox lb_FieldNames is populated through the procedure call "GetColumnNames(getdataset())". When an item in this listbox is selected, the user will click one of the 2 "Add" buttons to move to either lb_XFieldNames or lb_YFieldNames. Or, conversely, if one of the "Delete" buttons is clicked, the field is removed and re-added to lb_FieldNames.
When the item counts of these other 2 listboxes is >0, I want to change the visibility status of an image button ("imgb_GraphIt.Visible"). If the item counts go to zero as a result of deleting fields, the image button is to be set to not visible.
Everything with respect to moving items back and forth between listboxes works perfectly. Unfortunately, I cannot find a way to get the postback to execute after clicking any of the buttons. If both of the secondary listboxes are populated with one item each, the image button will not appear until after I select another item (thus raising the next postback event).
For informational purposes, the code for one of the buttons is as follows:
The SortLisBox() procedure works as it should. I have even removed it from the event procedure to prove it to be ineffectual in my problem. I am guessing this might take only 1 or 2 lines of code to resolve and I have every confidence that someone here will have the answer. Thanks.
Code:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If Not IsPostBack Then
lb_FieldNames.Items.Clear()
lb_XFieldNames.Items.Clear()
lb_YFieldNames.Items.Clear()
lb_YFieldNames.SelectedIndex = -1
lb_XFieldNames.AutoPostBack = True
lb_YFieldNames.AutoPostBack = True
If lb_FieldNames.Items.Count = 0 Then
GetColumnNames(getdataset())
End If
End If
Trace.Write("X Count: " & tb_xitem.Text)
Trace.Write("Y Count: " & tb_yitem.Text)
If (lb_XFieldNames.Items.Count > 0) And (lb_YFieldNames.Items.Count > 0) Then
imgb_GraphIt.Visible = True
Else : imgb_GraphIt.Visible = False
End If
Page.DataBind()
End Sub
Listbox lb_FieldNames is populated through the procedure call "GetColumnNames(getdataset())". When an item in this listbox is selected, the user will click one of the 2 "Add" buttons to move to either lb_XFieldNames or lb_YFieldNames. Or, conversely, if one of the "Delete" buttons is clicked, the field is removed and re-added to lb_FieldNames.
When the item counts of these other 2 listboxes is >0, I want to change the visibility status of an image button ("imgb_GraphIt.Visible"). If the item counts go to zero as a result of deleting fields, the image button is to be set to not visible.
Everything with respect to moving items back and forth between listboxes works perfectly. Unfortunately, I cannot find a way to get the postback to execute after clicking any of the buttons. If both of the secondary listboxes are populated with one item each, the image button will not appear until after I select another item (thus raising the next postback event).
For informational purposes, the code for one of the buttons is as follows:
Code:
Private Sub btn_Xadd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_Xadd.Click
If (lb_XFieldNames.Items.Count = 0) And (lb_FieldNames.SelectedIndex <> -1) Then
lb_XFieldNames.Items.Add(lb_FieldNames.SelectedItem)
lb_XFieldNames.SelectedItem.Selected = False
lb_FieldNames.Items.Remove(lb_XFieldNames.Items.Item(0).Value)
SortListBox(lb_FieldNames)
End If
The SortLisBox() procedure works as it should. I have even removed it from the event procedure to prove it to be ineffectual in my problem. I am guessing this might take only 1 or 2 lines of code to resolve and I have every confidence that someone here will have the answer. Thanks.