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


C# ListBox.DataBind方法代码示例

本文整理汇总了C#中ListBox.DataBind方法的典型用法代码示例。如果您正苦于以下问题:C# ListBox.DataBind方法的具体用法?C# ListBox.DataBind怎么用?C# ListBox.DataBind使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ListBox的用法示例。


在下文中一共展示了ListBox.DataBind方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: cargarLista

 protected void cargarLista(ListBox lista)
 {
     lista.DataSource = CursoDao.ObtenerTodo();
     lista.DataValueField = "id_curso";
     lista.DataTextField = "nombre";
     lista.DataBind();
 }
开发者ID:nyasan,项目名称:SI-ASA,代码行数:7,代码来源:InscripcionAlumnoACursos.aspx.cs

示例2: BindUsers

    public void BindUsers(ListBox ddl,DataSet ds)
    {
        if (ds.Tables[0].Rows.Count > 0)
        {
            ddl.DataSource = ds;
            ddl.DataTextField = "UName";
            ddl.DataValueField = "Email";
            ddl.DataBind();
            ddl.Items.Insert(0, common.AddItemToList("Select Users", "0"));
        }
        else
        {
            ddl.DataSource = null;
            ddl.Items.Clear();

        }
    }
开发者ID:frdharish,项目名称:WhitfieldAPPs,代码行数:17,代码来源:maintain_dlist.aspx.cs

示例3: btnConfirm_Click

 protected void btnConfirm_Click(object sender, EventArgs e)
 {
     int routineID = Convert.ToInt32(lb.SelectedItem.Value);
     Routine rtn = routManager.changeRoutineName(routineID, tbRoutineName.Text);
     int index = lb.SelectedIndex;
     if (rtn != null)
     {
         lb = (ListBox)this.Parent.FindControl("lbRoutines");
         lb.DataSource = routManager.getUsersRoutines(userID).ToList();
         lb.DataTextField = "name";
         lb.DataValueField = "id";
         lb.DataBind();
         lb.SelectedIndex = index;
         lblUniqueName.Visible = false;
     }
     else
         lblUniqueName.Visible = true;
 }
开发者ID:andeic,项目名称:Project-LimitBreaker,代码行数:18,代码来源:DeleteModifyRoutine.ascx.cs

示例4: LlenaListBox

    public static bool LlenaListBox(ListBox lsControl, string lsQuery, string lsMember, string lstrDisplay)
    {
        DataTable dslControl = new DataTable();

            try
            {
                dslControl = uti.RecuperaTabla(lsQuery);
                DataRow _datRowRenglonPrimerElemento = dslControl.NewRow();
                dslControl.Rows.InsertAt(_datRowRenglonPrimerElemento, 0);
                lsControl.DataSource = dslControl;
                lsControl.DataValueField = lsMember;
                lsControl.DataTextField = lstrDisplay;
                lsControl.DataBind();
                return true;
            }
            catch (Exception Ex)
            {
                //ERROR.AgregarError(Ex, "");
                return false;
            }
    }
开发者ID:torres93,项目名称:enaproce,代码行数:21,代码来源:Utilerias.cs

示例5: subCat


//.........这里部分代码省略.........

           items().CatID = subcat;

           items().CatID = subcat;

           switch (name)
        {

            case "lstcat":
                //lstcatsub1.DataSource = ds;
                //lstcatsub1.DataBind();
                lstcatsub1.Visible = true;
                lb = lstcat;
                lbn = lstcatsub1;
                counter =0;

                break;

            case "lstcatsub1":
                //lstcatsub1.DataSource = ds;   ;
                //lstcatsub1.DataBind();
                lstcatsub1.Visible = true; lstcatsub2.Visible = true;
                lb = lstcatsub1;
                lbn = lstcatsub2;
                counter = 1;

                break;

            case "lstcatsub2":

                lstcatsub1.Visible = true;

                //lstcatsub2.DataSource = ds; ;
                //lstcatsub2.DataBind();
                lstcatsub2.Visible = true; lstcatsub3.Visible = true;
               lb = lstcatsub2;
                lbn = lstcatsub3;
                counter = 2;
                break;

            case "lstcatsub3":

                lstcatsub1.Visible = true;
                lstcatsub2.Visible = true;

                lstcatsub3.Visible = true;
                lb  = lstcatsub3;
                lbn = lstcatsub3;
                counter = 3;
                break;

        }

           messages.arCats[counter] = lb.SelectedItem.ToString() + " ";

           for (int x = counter+1; x < messages.arCats.Count(); x++)
           {
           messages.arCats[x] = "";

           }

           if (((ListBox)sender).SelectedItem.ToString().IndexOf(">") == -1 || name == "lstcatsub3")
           {
           HtmlContainerControl catlstbx = (HtmlContainerControl)this.FindControl("catlstbx");

          custs().Organization.Orgitems.CatID = Convert.ToInt16( ((ListBox)sender).SelectedValue.ToString().Replace('>', ' '));

          custs_ = custs();

           catlstbx.Visible = true;
           return;

           }

        //messages.catID = subcat;

        //{
        //    HtmlContainerControl catlstbx = (HtmlContainerControl)this.FindControl("catlstbx");

        //    catlstbx.Visible = true;
        //}

        //else
        //{

        DataSet ds = UpdateDonate("S", "get_Categories", subcat, "");

        HtmlInputText hc = (HtmlInputText)this.FindControl("lisub");
         //   if (messages.cnt > 1) { hc.Value += " > "; }

        //messages.arCats[counter] = lb.SelectedItem.ToString() + " ";
        //messages.address += lb.SelectedItem.ToString() + " ";

        hc.Value =   messages.arCats.ToString() ; //messages.address;

        lbn.DataSource = ds; ;
        lbn.DataBind();

        //}
    }
开发者ID:elieli,项目名称:nonProfit,代码行数:101,代码来源:Default2.aspx.cs

示例6: Page_Load

    protected void Page_Load(object sender, EventArgs e)
    {
        sysManager = new SystemExerciseManager();
        routManager = new routineManager();

        if (Session["exercises"] == null)
        {
            exercises = new List<Exercise>();
            Session["exercises"] = exercises;
        }

        if (!IsPostBack)
        {
            lblUniqueName.Visible = false;
            pnlDescription.Visible = false;
            // full refresh of page will abandon current session
            Session.Abandon();
            lb = (ListBox)this.Parent.FindControl("lbRoutines");
            if (userID != null)
            {
                lb.DataSource = routManager.getUsersRoutines(userID).ToList();
                lb.DataTextField = "name";
                lb.DataValueField = "id";
                lb.DataBind();
            }

            // to get the id of the button so that enter = submit
            tbRoutineName.Attributes.Add("onKeyPress",
                 "doClick('" + btnConfirm.ClientID + "',event)");
        }
    }
开发者ID:andeic,项目名称:Project-LimitBreaker,代码行数:31,代码来源:CreateNewRoutine.ascx.cs

示例7: loadUserGroup

 private void loadUserGroup(string _schemeID, ListBox _lstBT)
 {
     ProcessEditScheme _processEditScheme = new ProcessEditScheme();
     _processEditScheme.SchemeID = _schemeID;
     _processEditScheme.ComID = Session["trkCompany"].ToString();
     _ds = _processEditScheme.getUserGroup();
     _lstBT.DataSource = _ds;
     _lstBT.DataTextField = "groupName";
     _lstBT.DataValueField = "groupID";
     _lstBT.DataBind();
 }
开发者ID:guarddoggps,项目名称:xtremek-static,代码行数:11,代码来源:Scheme.aspx.cs

示例8: BindListBox

 private void BindListBox(SqlCommand command, ListBox lb)
 {
     SqlDataReader reader = command.ExecuteReader();
     lb.DataSource = reader;
     lb.DataMember = "Name";
     lb.DataTextField = "Name";
     lb.DataValueField = "RoleId";
     lb.DataBind();
     reader.Close();
 }
开发者ID:alibinjamil,项目名称:datamedris,代码行数:10,代码来源:AddUsers.aspx.cs

示例9: bindlistbox

    //=================================================
    //功能描述:对listbox进行数据绑定
    //输入参数:sql,查询的SQL语句;listb,需要绑定的listbox控件
    //返回值:无
    //时间:2013.08.20
    //=================================================
    public static void bindlistbox(string sql, ListBox listb, string class_name, string id)
    {
        OleDbConnection conn = DB.Getconn();
            DataSet ds = getdataset(sql);
            listb.DataSource = ds.Tables[0].DefaultView;
            listb.DataTextField = class_name;
            listb.DataValueField = id;

        closeConnection();
            listb.DataBind();
    }
开发者ID:uwitec,项目名称:baihuibaihui,代码行数:17,代码来源:DB.cs

示例10: ThirdList

 public static void ThirdList(ListBox specialityListBox3, DropDownList industryDropDownList)
 {
     specialityListBox3.DataValueField = "JobID";
     specialityListBox3.DataTextField = "JobTitle";
     specialityListBox3.DataSource = BindSpecialityList3(HttpContext.Current.Session["LCID"].ToString(), industryDropDownList.SelectedIndex.ToString(CultureInfo.InvariantCulture) == "-1" ? "1" : industryDropDownList.SelectedValue.ToString(CultureInfo.InvariantCulture));
     specialityListBox3.DataBind();
 }
开发者ID:haithemaraissia,项目名称:Export,代码行数:7,代码来源:Utility.cs

示例11: BindUser

    //绑定用户列表
    private void BindUser(ListBox listBox)
    {
        //string strSql = "SELECT User_Account ,User_DspName FROM CMS_SYS_USERS where User_Active=1";
        //DataTable dt = DbHelperSQL.Query(strSql).Tables[0];

        DataTable dt = rightDA.getUserList().Tables[0];
        listBox.DataSource = dt;
        listBox.DataTextField = "User_DspName";
        listBox.DataValueField = "User_Account";
        listBox.DataBind();
    }
开发者ID:WuziyiaoKingIris20140501,项目名称:KFC,代码行数:12,代码来源:SetRight.aspx.cs

示例12: BindRole

    private void BindRole(ListBox listBox)
    {
        //string strSql = "SELECT Role_ID ,Role_Name FROM CMS_SYS_ROLES where Role_Active=1";
        //DataTable dt = DbHelperSQL.Query(strSql).Tables[0];

        DataTable dt = rightDA.getRoleList().Tables[0];

        listBox.DataSource = dt;
        listBox.DataTextField = "Role_Name";
        listBox.DataValueField = "Role_ID";
        listBox.DataBind();
    }
开发者ID:WuziyiaoKingIris20140501,项目名称:KFC,代码行数:12,代码来源:SetRight.aspx.cs

示例13: InitMembershipInfo

    public void InitMembershipInfo(ListBox listBoxSelectedItems, ListBox listBoxExistingItems)
    {
        try
        {
            DataTable tableSelectedItems = new DataTable();
            DataTable tableExistingItems = new DataTable();
            DataRow dataRow;
            Hashtable hashSelected = new Hashtable();
            List<Person> personlist = new List<Person>();
            List<JobPersonList> persononJoblist = new List<JobPersonList>();
            Collection<Person> persons = new Collection<Person>();
            personlist = SiteUtilities.GetAllPersonal();

            if (Request.QueryString["JobID"] != null)
            {

               persononJoblist = SiteUtilities.GetJobPersonal(new Guid(Request.QueryString["JobID"]));

                if (personlist != null)
                {

                    if (personlist.Count > 0)
                    {
                        tableSelectedItems.Columns.Add(new DataColumn("Name", typeof(string)));
                        tableSelectedItems.Columns.Add(new DataColumn("Id", typeof(Guid)));
                        foreach (JobPersonList person in persononJoblist)
                        {
                            dataRow = tableSelectedItems.NewRow();
                            dataRow[0] = person.Firstname + " " + person.Lastname;
                            dataRow[1] = person.PersonId;
                            tableSelectedItems.Rows.Add(dataRow);
                            hashSelected.Add(person.PersonId, "isSelected");
                            c_hiddenSelectedItems.Value += person.PersonId.ToString() +
                                                           DELIMITER_LIST_BOX_SELECTION;
                        }
                        listBoxSelectedItems.DataTextField = "Name";
                        listBoxSelectedItems.DataValueField = "Id";
                        listBoxSelectedItems.DataSource = tableSelectedItems;
                        listBoxSelectedItems.DataBind();
                    }

                }

                // Existing Items, (all the persons that the job is not allready added to)
                tableExistingItems.Columns.Add(new DataColumn("Name", typeof(string)));
                tableExistingItems.Columns.Add(new DataColumn("Id", typeof(Guid)));
                foreach (Person person in personlist)
                {
                    AddPersons(tableExistingItems, hashSelected, person);
                }
                listBoxExistingItems.DataTextField = "Name";
                listBoxExistingItems.DataValueField = "Id";
                listBoxExistingItems.DataSource = tableExistingItems;
                listBoxExistingItems.DataBind();

            }
        }
        catch
        {

        }
    }
开发者ID:huttan1,项目名称:spisab,代码行数:62,代码来源:Jobs.aspx.cs

示例14: InstantiateIn

    public void InstantiateIn(System.Web.UI.Control container)
    {
        switch (m_Mode)
        {
            case ListItemType.Item:
                {
                    Label descriptionLabel = new Label();
                    descriptionLabel.ID = m_ID;
                    descriptionLabel.Text = String.Empty;
                    descriptionLabel.DataBinding += new EventHandler(OnDataBinding);
                    container.Controls.Add(descriptionLabel);
                }
                break;
            case ListItemType.EditItem:
                {
                    if (m_IsReadOnly)
                    {
                        Label descriptionLabel = new Label();
                        descriptionLabel.ID = m_ID;
                        descriptionLabel.Text = String.Empty;
                        descriptionLabel.DataBinding += new EventHandler(OnDataBinding);
                        container.Controls.Add(descriptionLabel);
                    }
                    else
                    {
                        if (m_Type == HPMGridViewTemplateType.DropDownList)
                        {
                            DropDownList ddl = new DropDownList();
                            ddl.ID = m_ID;

                            ddl.DataTextField = "Value";
                            ddl.DataValueField = "Key";
                            ddl.DataSource = m_Ddlds;
                            ddl.DataBind();
                            ddl.DataBinding += new System.EventHandler(OnDataBinding);
                            container.Controls.Add(ddl);
                        }
                        else if (m_Type == HPMGridViewTemplateType.CheckBoxList)
                        {
                            ListBox lb = new ListBox();
                            lb.SelectionMode = ListSelectionMode.Multiple;
                            lb.DataTextField = "Value";
                            lb.DataValueField = "Key";
                            lb.ID = m_ID;
                            lb.DataSource = m_Ddlds;
                            lb.AutoPostBack = false;
                            lb.DataBind();
                            lb.DataBinding += new System.EventHandler(OnDataBinding);
                            container.Controls.Add(lb);
                        }
                        else
                        {
                            TextBox descriptionBox = new TextBox();
                            descriptionBox.ID = m_ID;
                            descriptionBox.Text = String.Empty;
                            descriptionBox.DataBinding += new EventHandler(OnDataBinding);
                            container.Controls.Add(descriptionBox);
                        }
                    }
                }
                break;
        }
    }
开发者ID:Hansoft,项目名称:hansoft-csharp-sdk-web-sample,代码行数:63,代码来源:HPMGridViewTemplate.cs

示例15: llenarLista

 public void llenarLista(ListBox dw, String sentencia, String nombre, String valor, String id)
 {
     conectar();
     DataSet Ds = new DataSet();
     SqlDataAdapter Adapter = new SqlDataAdapter(sentencia, con);
     Adapter.Fill(Ds, nombre);
     dw.DataSource = Ds.Tables[0].DefaultView;
     dw.DataTextField = valor; dw.DataValueField = id; dw.DataBind();
     desconectar();
 }
开发者ID:alejandroEGT,项目名称:babysitter,代码行数:10,代码来源:sql.cs


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