A
Andy B
I have the code below. It checks to see if there are any selected items in a
GridView displayed in wizardstep 1. It then shows the results of the
selection in step 2. I put this in the wizard.NextButton_Click event so I
can test for previous/next wizard steps. Everything works good except what
happens when nothing is selected. I want it to show a list item in an
unordered list the items that are selected (works good). If nothing is
selected, it should say that nothing is selected in an unordered listitem.
What I get instead is the "No news articles were selected" as well as the
items that were selected when there are selected items. Is there any way to
fix this problem?
GridView displayed in wizardstep 1. It then shows the results of the
selection in step 2. I put this in the wizard.NextButton_Click event so I
can test for previous/next wizard steps. Everything works good except what
happens when nothing is selected. I want it to show a list item in an
unordered list the items that are selected (works good). If nothing is
selected, it should say that nothing is selected in an unordered listitem.
What I get instead is the "No news articles were selected" as well as the
items that were selected when there are selected items. Is there any way to
fix this problem?
Code:
Dim StartList As String = "<UL>"
Dim EndList As String = "</UL>"
Dim ItemsInList As String = ""
' Iterate through the NewsToDelete.Rows property
For Each row As GridViewRow In NewsToDeleteGridView.Rows
' Access the CheckBox
Dim cb = DirectCast(row.FindControl("SelectCheckBox"), CheckBox)
If cb IsNot Nothing AndAlso cb.Checked Then
' Delete row! (Well, not really...)
' First, get the News ID for the selected row
Dim NewsID As New
Guid(NewsToDeleteGridView.DataKeys(row.RowIndex).Value.ToString())
' "Delete" the row
ItemsInList += String.Format( _
"<li>{0}({1})</li>", row.Cells(1).Text, NewsID)
'*** put delete code here [for future reference]
Else
ItemsInList = "<LI>No news articles were selected</LI>"
End If
Next
NewsToDeleteLabel.Text = StartList + ItemsInList + EndList