当前位置: 首页>>代码示例>>C#>>正文


C# WebControls.ListItem类代码示例

本文整理汇总了C#中System.Web.UI.WebControls.ListItem的典型用法代码示例。如果您正苦于以下问题:C# ListItem类的具体用法?C# ListItem怎么用?C# ListItem使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ListItem类属于System.Web.UI.WebControls命名空间,在下文中一共展示了ListItem类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: OnLoad

        /// <summary>
        /// Raises the <see cref="E:System.Web.UI.Control.Load"/> event.
        /// </summary>
        /// <param name="e">The <see cref="T:System.EventArgs"/> object that contains the event data.</param>
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            if (!Page.IsPostBack)
            {
                for (var i = DateTime.Now.Year; i < DateTime.Now.Year + 3; i++)
                {
                    var list = new ListItem
                                   {
                                       Text = i.ToString(),
                                       Value = i.ToString()
                                   };
                    ddlYear.Items.Add(list);
                }

                var month = Convert.ToDateTime("1/1/2000");
                for (var i = 0; i < 12; i++)
                {
                    var nextMonth = month.AddMonths(i);
                    var list = new ListItem
                                   {
                                       Text = nextMonth.ToString("MMMM"),
                                       Value = nextMonth.Month.ToString()
                                   };
                    ddlMonth.Items.Add(list);
                }
                ddlYear.SelectedValue = DateTime.Now.Year.ToString();
                ddlMonth.SelectedValue = DateTime.Now.Month.ToString();
            }

            btnGoToDate.Click += btnGoToDate_Click;
        }
开发者ID:maxpavlov,项目名称:FlexNet,代码行数:37,代码来源:BookCalendar.cs

示例2: BindDropDownNam

 protected void BindDropDownNam()
 {
     //ddlNam.Items.Clear();
     //lbMessage.Text = "";
     //SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings[1].ConnectionString);
     //con.Open();
     //string sql = "select year(ngay) Nam from CV_CapSo where ngay is not null group by year(ngay) order by year(ngay) desc";
     //SqlCommand cmd = new SqlCommand(sql, con);
     //SqlDataReader sdr = cmd.ExecuteReader();
     //if (sdr.HasRows)
     //{
     //    while (sdr.Read())
     //    {
     //        if (sdr.GetValue(sdr.GetOrdinal("Nam")).ToString() != null || sdr.GetValue(sdr.GetOrdinal("Nam")).ToString() != "")
     //        {
     //            int nam = Convert.ToInt32(sdr.GetValue(sdr.GetOrdinal("Nam")).ToString());
     //            ListItem li = new ListItem();
     //            li.Value = nam.ToString();
     //            li.Text = nam.ToString();
     //            ddlNam.Items.Add(li);
     //        }
     //    }
     //}
     //con.Close();
     for (int i = 0; i < 5; i++)
     {
         ListItem li = new ListItem();
         li.Value = (DateTime.Today.Year - i).ToString();
         li.Text = (DateTime.Today.Year - i).ToString();
         ddlNam.Items.Add(li);
     }
 }
开发者ID:chungnt88,项目名称:DesktopModules,代码行数:32,代码来源:LuuTruCongVanDen.ascx.cs

示例3: LoadOptions

        void LoadOptions()
        {
            
                ddlDistrict.DataSource = DistrictBO.GetAll(true);
                ddlDistrict.DataValueField = "DistrictID";
                ddlDistrict.DataTextField = "DistrictName";
                ddlDistrict.DataBind();
            

            ListItem li = new ListItem("[Gender]", "");
            ddlGender.Items.Add(li);
            li = new ListItem("Male", "M");
            ddlGender.Items.Add(li);
            li = new ListItem("Female", "F");
            ddlGender.Items.Add(li);


            li = new ListItem("[Status]", "");
            ddlStatus.Items.Add(li);
            li = new ListItem("Completed", "Completed");
            ddlStatus.Items.Add(li);
            li = new ListItem("Running", "Running");
            ddlStatus.Items.Add(li);

            //li = new ListItem("[Compensation]", "");
            //ddlCompensation.Items.Add(li);
            //li = new ListItem("Yes", "Yes");
            //ddlCompensation.Items.Add(li);
            //li = new ListItem("No", "No");
            //ddlCompensation.Items.Add(li);
        }
开发者ID:ayushman2013,项目名称:SaMI.WebV2,代码行数:31,代码来源:Index.aspx.cs

示例4: Page_Load

        protected void Page_Load(object sender, System.EventArgs e)
		{
			sbmt.Text = ui.Text("create");
			int NodeId = int.Parse(Request["nodeID"]);
			
			int[] allowedIds = new int[0];
			if (NodeId > 2) 
			{
				cms.businesslogic.Content c = new cms.businesslogic.media.Media(NodeId);
				allowedIds = c.ContentType.AllowedChildContentTypeIDs;
			}

		    var documentTypeList = businesslogic.media.MediaType.GetAllAsList().ToList();
		    foreach (var dt in documentTypeList)
			{
				ListItem li = new ListItem();
				li.Text = dt.Text;
				li.Value = dt.Id.ToString();
				
				if (NodeId > 2) 
				{
					foreach (int i in allowedIds) if (i == dt.Id) nodeType.Items.Add(li);
				}
                // The Any check is here for backwards compatibility, if none are allowed at root, then all are allowed
                else if (documentTypeList.Any(d => d.AllowAtRoot) == false || dt.AllowAtRoot)
					nodeType.Items.Add(li);
			}
		}
开发者ID:phaniarveti,项目名称:Experiments,代码行数:28,代码来源:media.ascx.cs

示例5: Page_Load

        protected void Page_Load(object sender, EventArgs e)
        {
            string app = gform("app");
            int tempid = 0;
            gnum(ref tempid, "id");
            switch (app)
            { 
                case "resettemplate":
                    reset_template(tempid);
                    showMessage("使用成功,刷新全部模板成功");
                    break;
                default:
                    break;

            }

            if (!IsPostBack)
            {
                TemplateTypeDal dal = new TemplateTypeDal();
                foreach (TemplateTypeInfo info in dal.view_list())
                {
                    ListItem item = new ListItem(info.templateName, info.templateName);

                    if ("template/"+info.templateName == TEMPLATEPATH)
                    {
                        item.Selected = true;
                    }
                    main_template.Items.Add(item);
                    //else
                    //main_template.Items.Add(new ListItem(info.templateName, info.templateName));
                }
            }
        }
开发者ID:joleye,项目名称:1.6,代码行数:33,代码来源:system.aspx.cs

示例6: Load_catesearch

        private void Load_catesearch()
        {
            var list = per.Load_danhmuc_search(1);
            if (list.Count > 0)
            {
                DataRelation relCat;
                DataTable tbl = DataUtil.LINQToDataTable(list);
                DataSet ds = new DataSet();
                ds.Tables.Add(tbl);

                tbl.PrimaryKey = new DataColumn[] { tbl.Columns["CAT_ID"] };
                relCat = new DataRelation("Category_parent", ds.Tables[0].Columns["CAT_ID"], ds.Tables[0].Columns["CAT_PARENT_ID"], false);

                ds.Relations.Add(relCat);
                DataSet dsCat = ds.Clone();
                DataTable CatTable = ds.Tables[0];

                DataUtil.TransformTableWithSpace(ref CatTable, dsCat.Tables[0], relCat, null);

                Drcate_search.DataSource = dsCat.Tables[0];
                Drcate_search.DataTextField = "CAT_NAME";
                Drcate_search.DataValueField = "CAT_ID";
                Drcate_search.DataBind();
            }
            ListItem l = new ListItem("Tất cả", "0");
            l.Selected = true;
            Drcate_search.Items.Insert(0, l);
        }
开发者ID:htphongqn,项目名称:esell.yeuthietkeweb.com,代码行数:28,代码来源:header-search.ascx.cs

示例7: Page_Load

        protected void Page_Load(object sender, EventArgs e)
        {
            templateID = int.Parse(Request["id"]);
            Template t = new Template(templateID);

            if (Skinning.StarterKitGuid(templateID).HasValue)
            {
                p_apply.Visible = true;

                string currentSkin = Skinning.GetCurrentSkinAlias(templateID);
                int templateRoot = FindTemplateRoot((CMSNode)t);

                dd_skins.Items.Add("Choose...");
                foreach (KeyValuePair<string,string> kvp in Skinning.AllowedSkins(templateRoot))
                {
                    ListItem li = new ListItem(kvp.Value, kvp.Key);
                    if (kvp.Key == currentSkin)
                        li.Selected = true;

                    dd_skins.Items.Add(li);
                }

                if (!string.IsNullOrEmpty(Skinning.GetCurrentSkinAlias(templateID)))
                {
                    ph_rollback.Visible = true;
                }
            }
        }
开发者ID:elrute,项目名称:Triphulcas,代码行数:28,代码来源:TemplateSkinning.aspx.cs

示例8: Page_Load

		protected void Page_Load(object sender, System.EventArgs e)
		{
			sbmt.Text = ui.Text("create");
			int NodeId = int.Parse(Request["nodeID"]);
			
			int[] allowedIds = new int[0];
			if (NodeId > 2) 
			{
				cms.businesslogic.Content c = new cms.businesslogic.media.Media(NodeId);
				allowedIds = c.ContentType.AllowedChildContentTypeIDs;
			}

			foreach(cms.businesslogic.ContentType dt in cms.businesslogic.media.MediaType.GetAll) 
			{
				ListItem li = new ListItem();
				li.Text = dt.Text;
				li.Value = dt.Id.ToString();
				
				if (NodeId > 2) 
				{
					foreach (int i in allowedIds) if (i == dt.Id) nodeType.Items.Add(li);
				} 
				else
					nodeType.Items.Add(li);
			}
		}
开发者ID:elrute,项目名称:Triphulcas,代码行数:26,代码来源:media.ascx.cs

示例9: Innit

        /// <summary>
        /// 初始化
        /// </summary>
        private void Innit()
        {
            ListItem nullItems = new ListItem();
            nullItems.Value = "";
            nullItems.Text = "请选择";


            //初始化项目编号
            ProjectNO_Input.Items.Add(nullItems);
            List<T_ProjectDicEntity> projectlist = BusinessFacadeShanlitech_Location.GetProjectList();
            foreach (T_ProjectDicEntity r in projectlist)
            {
                ListItem item = new ListItem();
                item.Text = r.ProjectName;
                item.Value = r.ID.ToString();
                ProjectNO_Input.Items.Add(item);
            }

            //初始化申请人
            Applicant_Input.Items.Add(nullItems);
            ArrayList userlist = BusinessFacadeShanlitech_Location.GetUserList();
            foreach (sys_UserTable r in userlist)
            {
                ListItem item = new ListItem();
                item.Value = r.UserID.ToString();
                item.Text = r.U_LoginName;
                if (!r.U_LoginName.Equals(""))
                {
                    Applicant_Input.Items.Add(item);
                }
            }

        }
开发者ID:zhanfuzhi,项目名称:shanligitproject,代码行数:36,代码来源:Manager.aspx.cs

示例10: initdata

        protected void initdata()
        {
            /*
            DropDownListDept.Items.Clear();
            List<Department> deps = BLL.admin.department.DepartmentManagement.getDepartments();
            foreach (Department dept in deps)
            {
                ListItem item = new ListItem();
                item.Text = dept.Name;
                item.Value = dept.Name;
                DropDownListDept.Items.Add(item);
            }
            */
            DropDownListType.Items.Clear();
            ListItem lin = new ListItem("");
            DropDownListType.Items.Add(lin);

            List<KQ_AttendanceType> t = BLL.Application.KQ.Attendance.MyAttendance.getAttendanceType();
            foreach (KQ_AttendanceType li in t)
            {
                ListItem l = new ListItem();
                l.Text = li.name;
                l.Value = li.Id.ToString();
                DropDownListType.Items.Add(l);
            }
            AspNetPager1.PageSize = BLL.pub.PubClass.PAGE_SIZE;
        }
开发者ID:kexinn,项目名称:Edu,代码行数:27,代码来源:AttendanceStatistic.aspx.cs

示例11: Page_Load

        protected void Page_Load(object sender, EventArgs e)
        {
            Page.MaintainScrollPositionOnPostBack = true;

            HttpCookie userCookie;
            HttpCookie passCookie;

            userCookie = Request.Cookies["UserID"];
            passCookie = Request.Cookies["UserPass"];

            if (userCookie == null || passCookie == null)
            {

                if (!IsPostBack)
                {
                    ListBox1.Items.Clear();
                    ListBox1.Width = 100;
                    ListBox1.Height = 60;
                    ListItem f = new ListItem("Female", "0");
                    ListItem m = new ListItem("Male", "1");
                    ListBox1.Items.Add(f);
                    ListBox1.Items.Add(m);
                }
            }
            else
            {
                Response.Redirect("..//Default.aspx");
            }
        }
开发者ID:villena,项目名称:StickyNotes,代码行数:29,代码来源:Register2.aspx.cs

示例12: MakeTree

        /// <summary>
        /// 绑定生成一个有树结构的下拉菜单
        /// </summary>
        /// <param name="dtNodeSets">菜单记录数据所在的表</param>
        /// <param name="strParentColumn">表中用于标记父记录的字段</param>
        /// <param name="strRootValue">第一层记录的父记录值(通常设计为0或者-1或者Null)用来表示没有父记录</param>
        /// <param name="strIndexColumn">索引字段,也就是放在DropDownList的Value里面的字段</param>
        /// <param name="strTextColumn">显示文本字段,也就是放在DropDownList的Text里面的字段</param>
        /// <param name="drpBind">需要绑定的DropDownList</param>
        /// <param name="i">用来控制缩入量的值,请输入-1</param>
        public static void MakeTree(DataTable dtNodeSets, string strParentColumn, string strRootValue, string strIndexColumn, string strTextColumn, DropDownList drpBind, int i)
        {
            //每向下一层,多一个缩入单位
            i++;

            DataView dvNodeSets = new DataView(dtNodeSets);
            dvNodeSets.RowFilter = strParentColumn + "=" + strRootValue;

            string strPading = "";  //缩入字符

            //通过i来控制缩入字符的长度,我这里设定的是一个全角的空格
            for (int j = 0; j < i; j++)
                strPading += " ";//如果要增加缩入的长度,改成两个全角的空格就可以了

            foreach (DataRowView drv in dvNodeSets)
            {
                TreeNode tnNode = new TreeNode();
                ListItem li = new ListItem(strPading + "├" + drv[strTextColumn].ToString(), drv[strIndexColumn].ToString());
                drpBind.Items.Add(li);
                MakeTree(dtNodeSets, strParentColumn, drv[strIndexColumn].ToString(), strIndexColumn, strTextColumn, drpBind, i);
            }

            //递归结束,要回到上一层,所以缩入量减少一个单位
            i--;
        }
开发者ID:NickQi,项目名称:TianheDemo,代码行数:35,代码来源:CommTree.cs

示例13: ddlPolicyGroup_SelectedIndexChanged

 protected void ddlPolicyGroup_SelectedIndexChanged(object sender, EventArgs e)
 {
     ddlSchedule.Items.Clear();
     ddlStandard.Items.Clear();
     ddlQuery.SelectCommand = "SELECT DISTINCT ScheduleUID, ScheduleName FROM compiledpolicies WHERE PolicyGroupUID " + ddlPolicyGroup.SelectedValue.ToString() + " ORDER BY ScheduleName";
     //Response.Write("ddlSchedule ddlQuery.SelectCommand (ddlPolicyGroup_SelectedIndexChanged): " + ddlQuery.SelectCommand.ToString() + "<br>");
     SqlDataReader sqlReader = (SqlDataReader)ddlQuery.Select(DataSourceSelectArguments.Empty);
     if (sqlReader.HasRows)
     {
         while (sqlReader.Read())
         {
             ListItem item = new ListItem(sqlReader[1].ToString(), "= " + sqlReader[0].ToString(), true);
             ddlSchedule.Items.Add(item);
         }
     }
     ListItem scheduleall = new ListItem("Narrow results by schedule...", " != ''", true);
     scheduleall.Selected = true;
     ddlSchedule.Items.Add(scheduleall);
     ddlQuery.SelectCommand = "SELECT DISTINCT StandardUID, StandardName FROM compiledpolicies WHERE PolicyGroupUID " + ddlPolicyGroup.SelectedValue.ToString() + " AND ScheduleUID " + ddlSchedule.SelectedValue.ToString() + " ORDER BY StandardName";
     //Response.Write("ddlStandard ddlQuery.SelectCommand (ddlPolicyGroup_SelectedIndexChanged): " + ddlQuery.SelectCommand.ToString() + "<br>");
     sqlReader = (SqlDataReader)ddlQuery.Select(DataSourceSelectArguments.Empty);
     if (sqlReader.HasRows)
     {
         while (sqlReader.Read())
         {
             ListItem item = new ListItem(sqlReader[1].ToString(), "= " + sqlReader[0].ToString(), true);
             ddlStandard.Items.Add(item);
         }
     }
     ListItem standardall = new ListItem("Narrow results by schedule...", " != ''", true);
     standardall.Selected = true;
     ddlStandard.Items.Add(standardall);
 }
开发者ID:justinkreft,项目名称:retentionscheduleapplication,代码行数:33,代码来源:policysearch.aspx.cs

示例14: OnPreRender

        protected override void OnPreRender(EventArgs e)
        {
            if ((lstLists.SelectedIndex > -1) & (!UpdateListProperties))
            {
                SelectedListId = new Guid(lstLists.SelectedValue);
            }

            lstLists.Items.Clear();
            SPWeb site = SPContext.Current.Web;
            foreach (SPList list in site.Lists)
            {
                ListItem listItem = new ListItem(list.Title, list.ID.ToString());
                lstLists.Items.Add(listItem);
            }

            // when the page reloads, default the selected item to the current list
            if (SelectedListId != Guid.Empty)
            {
                lstLists.Items.FindByValue(SelectedListId.ToString()).Selected = true;
            }

            if (UpdateListProperties)
            {
                SPList list = SPContext.Current.Web.Lists[SelectedListId];
                lblListTitle.Text = list.Title;
                lblListID.Text = list.ID.ToString().ToUpper();
                lblListIsDocumentLibrary.Text = (list is SPDocumentLibrary).ToString();
                lblListIsHidden.Text = list.Hidden.ToString();
                lblListItemCount.Text = list.ItemCount.ToString();
                lnkListUrl.Text = list.DefaultViewUrl;
                lnkListUrl.NavigateUrl = list.DefaultViewUrl;
            }
        }
开发者ID:Adotob,项目名称:CriticalPathGSATampa1015,代码行数:33,代码来源:ListInspectorWebPart.ascx.cs

示例15: dtgUsers_PreRender

        protected void dtgUsers_PreRender(object sender, EventArgs e)
        {
            if (dtgUsers.BottomPagerRow != null)
            {
                ((Label)dtgUsers.BottomPagerRow.FindControl("lbTotalPages")).Text = dtgUsers.PageCount.ToString();

                //This makes the first and last button disappear when on the first and last pages.
                ((LinkButton)dtgUsers.BottomPagerRow.FindControl("lbtnFirst")).Visible = dtgUsers.PageIndex != 0;
                ((LinkButton)dtgUsers.BottomPagerRow.FindControl("lbtnLast")).Visible = dtgUsers.PageCount != (dtgUsers.PageIndex + 1);

                DropDownList ddlistPageof = (DropDownList)dtgUsers.BottomPagerRow.FindControl("ddlPageItems");
                ddlistPageof.SelectedIndex = ddlistPageof.Items.IndexOf(ddlistPageof.Items.FindByValue(ViewState["DropDownPageItems"].ToString()));
                DropDownList ddlistPageno = (DropDownList)dtgUsers.BottomPagerRow.FindControl("ddlNumberPages");
                ddlistPageno.Items.Clear();
                for (int i = 1; i <= dtgUsers.PageCount; i++)
                {
                    ListItem liTemp = new ListItem();
                    liTemp.Text = i.ToString();
                    liTemp.Value = i.ToString();
                    ddlistPageno.Items.Add(liTemp);
                }
                if (dtgUsers.PageCount != 0)
                {
                    ddlistPageno.SelectedIndex = dtgUsers.PageIndex;
                    ddlistPageno.DataBind();
                }
            }
        }
开发者ID:hoangtung56pm,项目名称:KPINew,代码行数:28,代码来源:DanhGiaThang_LanhDao_KD.ascx.cs


注:本文中的System.Web.UI.WebControls.ListItem类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。