本文整理汇总了C#中System.Web.UI.WebControls.ListItemCollection.Cast方法的典型用法代码示例。如果您正苦于以下问题:C# ListItemCollection.Cast方法的具体用法?C# ListItemCollection.Cast怎么用?C# ListItemCollection.Cast使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Web.UI.WebControls.ListItemCollection
的用法示例。
在下文中一共展示了ListItemCollection.Cast方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BuildMergeVars
/// <summary>
/// A small helper method to create the basic merge varibles from a person (FNAME, LNAME, BIRTHDATE, GENDER).
/// </summary>
/// <param name="person"></param>
/// <param name="merges"></param>
private static void BuildMergeVars( Person person, MCMergeVar[] merges, ListItemCollection listItemCollection)
{
merges[0].tag = "FNAME";
merges[0].val = person.FirstName;
merges[1].tag = "LNAME";
merges[1].val = person.LastName;
if ( person.BirthDate != Constants.NULL_DATE )
{
merges[2].tag = "BIRTHDATE";
merges[2].val = person.BirthDate.ToShortDateString();
}
merges[3].tag = "GENDER";
merges[3].val = person.Gender.ToString();
merges[4].tag = "INTERESTS";
// Turn the selected items in the checkbox into a comma delimited list of interests (ex: "A,B,C")
var values = listItemCollection.Cast<ListItem>().Where( n => n.Selected ).Select( n => n.Value ).ToArray();
merges[4].val = string.Join( ",", values );
}