本文整理汇总了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();
}
示例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();
}
}
示例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;
}
示例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;
}
}
示例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();
//}
}
示例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)");
}
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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
{
}
}
示例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;
}
}
示例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();
}