Hi,
There are a number of ways you can achieve the same flow.
Switch( e.item.itemType )
{
case ListItemType.Item:
case ListItemType.AlternatingItem:
case ListItemType.EditItem:
[code]
break;
case ListItemType.SelectedItem:
[code]
break;
case ListItemType.Header:
case ListItemType.Footer:
[code]
break;
default:
[default catch all code if required]
break;
}
Alternativly you might want to jump from one case to another for example
Switch( e.item.itemType )
{
case ListItemType.Item:
[code]
break;
case ListItemType.AlternatingItem:
[code]
goto case ListItemType.Item;
case ListItemType.EditItem:
[code]
break;
case ListItemType.SelectedItem:
[code]
goto case ListItemType.EditItem;
default:
[default catch all code if required]
break;
}
Here the item will contain code for items. The AlternatingItem will contain code for the alternating item such as a colour then jump to the Item case statement before exiting the switch. Obviously you have to think about the code you are adding i.e. if you set the colour in the AlternatingItem and then call Item where it sets the default colour this will replace the one set in the AlternatingItem. Ultimatly you would not set the colour here as the control has the relevant properties but this just demonstrates two possible methods
- Mike
---------------------------------------------------------------------------------
<a href="http://www.cogitar.net"> Cogitar Software. (www.cogitar.net) </a>
http://www.web-dominion.co.uk Web-Dominion. (Web Design and hosting )
---------------------------------------------------------------------------------
"John" <jh******@msn.com> wrote in message news:Ox**************@TK2MSFTNGP12.phx.gbl...
Is there a way in c# to have a switch statement with multiple expressions
like in VB.net?
Select Case e.Item.ItemType
Case ListItemType.Item, ListItemType.AlternatingItem,
ListItemType.EditItem
[code]
Case expression, expression2
[code]
End Select