本文整理汇总了C#中ListItemCollection.Add方法的典型用法代码示例。如果您正苦于以下问题:C# ListItemCollection.Add方法的具体用法?C# ListItemCollection.Add怎么用?C# ListItemCollection.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ListItemCollection
的用法示例。
在下文中一共展示了ListItemCollection.Add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Page_Load
public void Page_Load()
{
try
{
if (!IsPostBack)
{
ListItemCollection c = new ListItemCollection();
c.Add(new ListItem("Total Posts", TransitStats.PostsCount.ToString()));
c.Add(new ListItem("Total Images", TransitStats.ImagesCount.ToString()));
if (!DisqusEnabled)
{
c.Add(new ListItem("Total Comments", TransitStats.CommentsCount.ToString()));
}
if (SessionManager.CountersEnabled)
{
c.Add(new ListItem("Rss Hits", string.Format("{0} since {1}",
TransitStats.RssCount.Count, TransitStats.RssCount.Created.ToString("d"))));
c.Add(new ListItem("Atom Hits", string.Format("{0} since {1}",
TransitStats.AtomCount.Count, TransitStats.AtomCount.Created.ToString("d"))));
}
grid.DataSource = c;
grid.DataBind();
summaryLinks.Visible = SessionManager.CountersEnabled;
}
}
catch (Exception ex)
{
ReportException(ex);
}
}
示例2: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
try
{
if (!IsPostBack)
{
SetDefaultButton(save);
ListItemCollection intervals = new ListItemCollection();
intervals.Add(new ListItem("Never", Convert.ToString(-1)));
intervals.Add(new ListItem("Every Request", Convert.ToString(0)));
intervals.Add(new ListItem("One Minute", Convert.ToString(60)));
intervals.Add(new ListItem("Five Minutes", Convert.ToString(5 * 60)));
intervals.Add(new ListItem("Ten Minutes", Convert.ToString(10 * 60)));
intervals.Add(new ListItem("Half Hour", Convert.ToString(30 * 60)));
intervals.Add(new ListItem("One Hour", Convert.ToString(60 * 60)));
intervals.Add(new ListItem("Twelve Hours", Convert.ToString(12 * 60 * 60)));
intervals.Add(new ListItem("One Day", Convert.ToString(24 * 60 * 60)));
inputInterval.DataSource = intervals;
inputInterval.DataBind();
inputType.DataSource = Enum.GetValues(typeof(TransitFeedType));
inputType.DataBind();
if (RequestId > 0)
{
inputName.Text = Feed.Name;
inputUrl.Text = Feed.Url;
inputDescription.Text = Feed.Description;
inputXsl.PostedFile = new UploadControl.HttpPostedFile(string.IsNullOrEmpty(Feed.Xsl) ? "None" : string.Format("{0} bytes", Feed.Xsl.Length));
ListItem li = inputInterval.Items.FindByValue(Feed.Interval.ToString());
if (li == null)
{
li = new ListItem(string.Format("{0} Seconds", Feed.Interval), Feed.Interval.ToString());
inputInterval.Items.Add(li);
}
inputInterval.ClearSelection();
li.Selected = true;
inputUsername.Text = Feed.Username;
inputPassword.Attributes["value"] = Feed.Password;
inputType.Items.FindByValue(Feed.Type.ToString()).Selected = true;
}
}
}
catch (Exception ex)
{
ReportException(ex);
}
}
示例3: MyDropDown
ComboBoxCell MyDropDown()
{
var combo = new ComboBoxCell ();
var items = new ListItemCollection ();
items.Add (new ListItem{ Text = "Item 1" });
items.Add (new ListItem{ Text = "Item 2" });
items.Add (new ListItem{ Text = "Item 3" });
items.Add (new ListItem{ Text = "Item 4" });
combo.DataStore = items;
return combo;
}
示例4: OnEnable
void OnEnable()
{
mCollection = new ListItemCollection();
for (int i = 0; i < 20; i++) {
mCollection.Add(new LabelListItem("Item " + i.ToString() + " example"));
}
}
示例5: ExecuteSQL
public static ListItemCollection ExecuteSQL(string sql = "", string text = "", string value = "",
List<SqlParameter> parameters = null)
{
ListItemCollection lic = new ListItemCollection();
using (SqlConnection conn = new SqlConnection(Connection))
{
conn.Open();
using (SqlCommand cmd = new SqlCommand(sql, conn))
{
if (parameters != null)
{
cmd.Parameters.AddRange(parameters.ToArray());
}
using (SqlDataReader reader = cmd.ExecuteReader())
{
if (reader.HasRows)
{
while (reader.Read())
{
lic.Add(new ListItem(reader[text].ToString(),
reader[value].ToString()));
}
}
}
}
}
return lic;
}
示例6: Add_Click
protected void Add_Click(object sender, EventArgs e)
{
ListItemCollection removeList = new ListItemCollection();
// deselect all items
foreach (ListItem item in SelectedMembers.Items)
{
item.Selected = false;
}
for (int i = 0; i < AvailableMembers.Items.Count; i++)
{
ListItem li = AvailableMembers.Items[i];
if (!li.Selected) continue;
// check to see if user is already selected
IUserActivity attendee = Activity.Attendees.FindAttendee(li.Value);
if (attendee != null) continue;
li.Attributes.Add("style", "color:lightgrey");
li.Attributes.Add("status", "unconfirmed");
SelectedMembers.Items.Add(li);
Activity.Attendees.Add(li.Value);
removeList.Add(li);
}
foreach (ListItem li in removeList)
{
AvailableMembers.Items.Remove(li);
}
}
示例7: btnPreview_Click
/// <summary>
/// Previews the event info entered by the user in a new window.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnPreview_Click(object sender, EventArgs e)
{
if (this.IsValid)
{
string WebinarRecordingID = CareerCruisingWeb.CCLib.Common.Strings.GetQueryString("WebinarRecordingID");
// if showing criteria for an existing event
if (WebinarRecordingID != "")
{
ClientScript.RegisterStartupScript(this.Page.GetType(), "New Window", "window.open('../../../Public/Webinars/VideoDetails.aspx?WebinarRecordingID=" + WebinarRecordingID + "','','height=580,width=600,scrollbars=1,resizable=1');", true);
}
else
{
Session["WebinarVideoDisplayTitle"] = lblDisplayTitle.Text;
Session["WebinarVideoRegistrationURL"] = CareerCruisingWeb.CCLib.Common.Strings.GenerateHttpLink(txtRegistrationUrl.Text.Trim());
string commandText = "SELECT Description FROM Webinar_DescriptionsLookup WHERE WebinarDescriptionID = " + ddlListTitle.SelectedValue;
string webinarDescription = CareerCruisingWeb.CCLib.Common.DataAccess.GetValue(commandText).ToString();
Session["WebinarVideoDescription"] = webinarDescription;
Session["WebinarVideoPresenterFullName"] = ddlPresenter.SelectedItem.Text;
commandText = "SELECT Title, Bio, PhotoImagePath FROM Webinar_PresenterLookup WHERE WebinarPresenterID = " + ddlPresenter.SelectedValue;
DataRow presenterInfo = CareerCruisingWeb.CCLib.Common.DataAccess.GetDataTable(commandText).Rows[0];
Session["WebinarVideoPresenterTitle"] = presenterInfo["Title"].ToString();
Session["WebinarVideoPresenterBio"] = presenterInfo["Bio"].ToString();
Session["WebinarVideoPresenterPhotoImagePath"] = presenterInfo["PhotoImagePath"].ToString();
Session["WebinarVideoRecordingDate"] = DateTime.Parse(txtSessionDates.Text.Trim()).ToString("MM/dd/yyyy");
commandText = "SELECT wal.WebinarAudienceID, wal.AudienceDescription_EN ";
commandText += "FROM Webinar_AudienceLookup wal ";
commandText += "INNER JOIN Webinar_DescriptionsAudience wda ON wal.WebinarAudienceID = wda.WebinarAudienceID ";
commandText += "WHERE wda.WebinarDescriptionID = " + ddlListTitle.SelectedValue;
commandText += "GROUP BY wal.AudienceDescription_EN, wal.WebinarAudienceID ";
commandText += "ORDER BY wal.AudienceDescription_EN";
DataTable webinarAudience = CareerCruisingWeb.CCLib.Common.DataAccess.GetDataTable(commandText);
if (webinarAudience.Rows.Count > 0)
{
ListItemCollection collection = new ListItemCollection();
foreach (DataRow row in webinarAudience.Rows)
{
collection.Add(new ListItem(row["AudienceDescription_EN"].ToString()));
}
Session["WebinarVideoAudienceDescriptionList"] = collection;
}
else
{
Session["WebinarVideoAudienceDescriptionList"] = null;
}
ClientScript.RegisterStartupScript(this.Page.GetType(), "New Window", "window.open('../../../Public/Webinars/VideoDetails.aspx','','height=580,width=600,scrollbars=1,resizable=1');", true);
}
}
}
示例8: AddAddsToNewGroupIfGroupDoesntExist
public void AddAddsToNewGroupIfGroupDoesntExist()
{
var list = new ListItemCollection<string>();
list.AddGroup("Hello", new List<string> { "Foo" });
list.Add("World", "Bar");
list.Should().HaveCount(2);
list.Should().Contain(g => g.Title == "Hello" && g.Count == 1 && g[0] == "Foo");
list.Should().Contain(g => g.Title == "World" && g.Count == 1 && g[0] == "Bar");
}
示例9: AddAddsToExistingGroupIfGroupDoesExist
public void AddAddsToExistingGroupIfGroupDoesExist()
{
var list = new ListItemCollection<string>();
list.AddGroup("Hello", new List<string> { "Foo" });
list.Add("Hello", "Bar");
list.Should().HaveCount(1);
list.Should().Contain(g => g.Title == "Hello" && g.Count == 2 &&
g.Contains("Foo") && g.Contains("Bar"));
}
示例10: AdAll_Click
protected void AdAll_Click(object sender, EventArgs e)
{
ListItemCollection liC = new ListItemCollection();
foreach (ListItem li in AvForumsList.Items)
{
MdForumsList.Items.Add(li);
li.Selected = false;
liC.Add(li);
}
foreach (ListItem li in liC)
AvForumsList.Items.Remove(li);
}
示例11: RemoveSelectedFromBasket_ButtonClick
protected void RemoveSelectedFromBasket_ButtonClick(object sender, EventArgs e)
{
ListItemCollection ItemsForRemoveActionInBasketListBox = new ListItemCollection();
foreach (ListItem CurrentItem in this.ListBoxSelectedProducts.Items)
{
if (CurrentItem.Selected)
{
this.ListBoxProducts.Items.Add(CurrentItem);
ItemsForRemoveActionInBasketListBox.Add(CurrentItem);
}
}
foreach (ListItem CurrentItem in ItemsForRemoveActionInBasketListBox)
{
this.ListBoxSelectedProducts.Items.Remove(CurrentItem);
}
}
示例12: AdAll_Click
protected void AdAll_Click(object sender, EventArgs e)
{
ListItemCollection liC = new ListItemCollection();
foreach (ListItem li in AvForumsList.Items)
{
ArchiveForumsList.Items.Add(li);
li.Selected = false;
liC.Add(li);
}
foreach (ListItem li in liC)
AvForumsList.Items.Remove(li);
ArchiveBtn.Enabled = true;
Panel2.Visible = false;
}
示例13: Ad2_Click
protected void Ad2_Click(object sender, EventArgs e)
{
if (AvModsList.SelectedItem != null)
{
ListItemCollection liC = new ListItemCollection();
foreach (ListItem li in AvModsList.Items)
if (li.Selected)
{
CurModsList.Items.Add(li);
li.Selected = false;
liC.Add(li);
}
foreach (ListItem li in liC)
AvModsList.Items.Remove(li);
}
}
示例14: SetupList
ObservableCollection<ListItemCollection> SetupList()
{
var allListItemGroups = new ObservableCollection<ListItemCollection>();
foreach (var item in ListItemCollection.GetSortedData())
{
// Attempt to find any existing groups where theg group title matches the first char of our ListItem's name.
var listItemGroup = allListItemGroups.FirstOrDefault(g => g.Title == item.Label);
// If the list group does not exist, we create it.
if (listItemGroup == null)
{
listItemGroup = new ListItemCollection(item.Label);
listItemGroup.Add(item);
allListItemGroups.Add(listItemGroup);
}
else
{ // If the group does exist, we simply add the demo to the existing group.
listItemGroup.Add(item);
}
}
return allListItemGroups;
}
示例15: Button1_Click
protected void Button1_Click(object sender, EventArgs e)
{
var from = Convert.ToSingle(tbPriceFrom.Text);
var to = Convert.ToSingle(tbPriceTo.Text);
_products = ProductController.GetByPrice(from, to);
var options = new ListItemCollection();
foreach (var productModel in _products)
options.Add(new ListItem {Text = productModel.Name, Value = productModel.Name});
ProductDropdown.DataValueField = "Value";
ProductDropdown.DataTextField = "Text";
ProductDropdown.DataSource = options;
ProductDropdown.DataBind();
// set new variables
if (_products.Count <= 0) {
image.ImageUrl = tbPrice.Text = "";
} else {
image.ImageUrl = _products[0].ImageName;
tbPrice.Text = _products[0].Price.ToString();
}
}