Hi guys,
I'm new to VB.NET... I have a program that populates a ListBox from a SqlDataSource. There is a button beneath it that removes the selected item from the database...
I need to check whether the last item was deleted, this way, I can return to the main screen once it has been...
Pay attention to the "If" statement at the bottom... That's where I'm having trouble...
The "If" Statement at the bottom is what I'm trying to check with, but the count value isn't updated until the sub exits... :(
Since this is a webforms application, i'm not sure how to run that check immediately after the delete executes... Should I seperate it all into a private function
and run the function on button click? like:
I feel like I'm missing something simple here... Thanks
I'm new to VB.NET... I have a program that populates a ListBox from a SqlDataSource. There is a button beneath it that removes the selected item from the database...
I need to check whether the last item was deleted, this way, I can return to the main screen once it has been...
Pay attention to the "If" statement at the bottom... That's where I'm having trouble...
Code:
Protected Sub deleteRpt_Click(sender As Object, e As EventArgs) Handles deleteRpt.Click
Me.SetConnString()
Dim children As Boolean
Dim pickedKey = CStr(rptListBox.SelectedValue)
children = checkForChildren(pickedKey, "Report")
If (Not children) Then
fldListSrc.SelectCommand = rptStart + ViewState("Key")
fldListSrc.DeleteCommand =deleteStart + pickedKey
fldListSrc.Delete()
rptErrLabel.Visible = False
Else
rptErrLabel.Text = "ERROR: There are parameters in this report that must be deleted first!"
rptErrLabel.Visible = True
End If
UpdateDropdown()
UpdatePanel1.Update()
If (fldListBox.Items.Count = 0) Then
Me.reset()
End If
End Sub
Since this is a webforms application, i'm not sure how to run that check immediately after the delete executes... Should I seperate it all into a private function
and run the function on button click? like:
Code:
Protected Sub deleteRpt_Click(sender As Object, e As EventArgs) Handles deleteRpt.Click
DeleteFunciton()
If (fldListBox.Items.Count = 0) Then
Me.reset()
End If
End Sub