Can you use if statements in switches?

monas

New Member
Is it possible to use a IF statement withing the \[code\]case\[/code\] of a \[code\]switch\[/code\] statement? I have tried the following code but nothing happens. I have verified that SectionID does not equal -1 but the page does not process anything, it will not shoot off the \[code\]Server.Transfer\[/code\] nor propagate the assignments to the \[code\]ListView\[/code\] or \[code\]Labels\[/code\].\[code\]case "Media": if (SectionID != "-1") { Server.Transfer("/Staff/Section.aspx"); } lvSearchResults.DataSource = SQLHelper.GetDataByQuery("SELECT SectionID AS ID, ShortName AS Title, Synopsis AS Descript, 'Section' AS PageName FROM dbo.tblSectionInfo WHERE ShortName != 'Unknown' ORDER BY SectionTitle"); lvSearchResults.DataBind(); lblTitleRow.Text = "Add Section"; lblDescriptionRow.Text = "Add new section home page."; btnAddNewItem.PostBackUrl = "/Staff/Section.aspx";break;\[/code\]
 
Back
Top