本文整理汇总了C#中System.Web.UI.WebControls.ListItemCollection.Insert方法的典型用法代码示例。如果您正苦于以下问题:C# ListItemCollection.Insert方法的具体用法?C# ListItemCollection.Insert怎么用?C# ListItemCollection.Insert使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Web.UI.WebControls.ListItemCollection
的用法示例。
在下文中一共展示了ListItemCollection.Insert方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FillToListBox
public static void FillToListBox(ListItemCollection lstItems, DataTable source, int rootId, bool superUser)
{
DataRow[] drCommands = source.Select("CommandParentID = " + rootId);
foreach(DataRow row in drCommands)
{
if (!superUser && (bool)row["IsSuperUser"]) continue;
ListItem rootItem = new ListItem(row["CommandName"].ToString(), row["CommandID"].ToString());
rootItem.Attributes.Add("Level","0");
lstItems.Add(rootItem);
LoadForCurListItem(lstItems, rootItem, source, superUser);
}
lstItems.Insert(0, new ListItem("Root","0"));
}
示例2: InitListItems
/// <summary>
/// 绑定控件的ListItem项
/// </summary>
/// <param name="LIC"></param>
/// <param name="IsFistNull"></param>
public void InitListItems(ListItemCollection LIC, bool IsFistNull)
{
if (LIC.Count > 0)
{
LIC.Clear();
}
Hashtable ht = GetTextValue();
foreach (DictionaryEntry de in ht)
{
LIC.Add(new ListItem(de.Value.ToString(), de.Key.ToString()));
}
if (IsFistNull)
{
LIC.Insert(0, "");
}
}
示例3: LoadEmailTemplateItems
private void LoadEmailTemplateItems(string templateUrl, string selectedValue)
{
try
{
txtTemplateName.Items.Clear();
ListItemCollection DropdownListSource = new ListItemCollection();
SPList list = Utility.GetListFromURL(templateUrl);
SPQuery query = new SPQuery() { Query = "<OrderBy><FieldRef Name='Title' Ascending='True' /></OrderBy>" };
SPListItemCollection items = list.GetItems(query);
DropdownListSource.Insert(0, (new ListItem() { Text = "Select a template", Value = string.Empty }));
foreach (SPListItem item in items)
{
DropdownListSource.Add(new ListItem() { Text = item["Title"] as string, Value = item["Title"] as string });
}
if (DropdownListSource.Count > 0)
{
BindDropDownSource(txtTemplateName, DropdownListSource);
if (string.IsNullOrEmpty(selectedValue))
txtTemplateName.Items[0].Selected = true;
else
txtTemplateName.SelectedValue = selectedValue;
//Load Extend DropDownList Source
if (AssociateControls != null)
{
foreach (DropDownList ddl in AssociateControls)
{
BindDropDownSource(ddl, DropdownListSource);
}
}
}
}
catch
{
if (!string.IsNullOrEmpty(templateUrl) && allowNull == false)
{
txtTemplateName.Items.Clear();
txtTemplateUrlValidator.ErrorMessage = "Cannot get email template from this url";
txtTemplateUrlValidator.IsValid = false;
}
}
}