asp.net dropdownlist和listbox
if (!IsPostBack)
{
//页面初次加载时执行这里的内容
DataSet ds = new DataSet(); //数据集
ds.Tables.Add("stu");
ds.Tables["stu"].Columns.Add("id",typeof(int));
ds.Tables["stu"].Columns.Add("name", typeof(string));
ds.Tables["stu"].Columns.Add("score", typeof(int));
ds.Tables["stu"].Rows.Add(new object[] { 1, "张三", 100 });
ds.Tables["stu"].Rows.Add(new object[] { 2, "李四", 100 });
ds.Tables["stu"].Rows.Add(new object[] { 3, "周五", 100 });
ds.Tables["stu"].Rows.Add(new object[] { 4, "郑六", 100 });
ds.Tables["stu"].Rows.Add(new object[] { 5, "甲七", 100 });
this.ListBox1.DataSource = ds.Tables["stu"];
this.ListBox1.DataTextField = "name"; //列表显示的字段
this.ListBox1.DataValueField = "id";
this.ListBox1.DataBind(); //this.ListBox1.SelectedIndex 选中项的索引
//this.ListBox1.SelectedItem 选中项
//this.ListBox1.SelectedItem.Text 选中项的内容
//this.ListBox1.SelectedItem.Value; 选中项的值
//this.ListBox1.SelectedValue 选中项的值 }
asp.net dropdownlist和listbox的更多相关文章
- 《ASP.NET》数据绑定—DropDownList、ListBox
DropDownList和ListBox实现两级联动功能.他们也能够将从后台数据库中搜选的出来的信息加以绑定.这里要实现的功能是在DropDownList中选择"省",然后让Lis ...
- asp.net中的ListBox控件添加双击事件
问题:在Aspx页里的ListBox A中添加双击事件,将选中项添加到另一个ListBox B中,双击ListBox B中的选中项,删除当前选中项 页面: <asp:ListBox ID=&qu ...
- Asp.net DropDownList 自定义样式(想怎么改就怎么改!)
最近在做一个asp.net的项目,需要对默认的dropdownlist样式进行美化,固有的dropdownlist的小箭头实在让人无法接受,于是开始在百度,google 上下求索,天不负有心人,终于找 ...
- 转:打造DropDownList,TreeView,ListBox无限极分类目录树
[csharp] view plaincopyprint? #region DropDownList无限递归显示层次关系 /// <summary> /// 创建无限分级下拉列表框 /// ...
- asp.net DropDownList无刷新ajax二级联动实现详细过程
只适合新手制作DropDownList无刷新ajax二级联动效果: 数据库实现,添加两表如图:表1,pingpai,表2,type,具体数据库实现看自己的理解: //页面主要代码: <asp:S ...
- asp.net DropDownList的AppendDataBoundItems属性
个人笔记 当设置DropDownList的AppendDataBoundItems属性为true,是将数据绑定项追加到静态声明的列表上,即在绑定之前可加入静态列表项. 例如: 前台这么写: <a ...
- jQuery UI Autocomplete Combobox 配 ASP.NET DropDownList
0.引言 1.起因 一开始使用Autocomplete做了一个自动补全的文本框,如上图.后来因业务需要希望能在这个文本框的边上做个下拉列表按钮,一按就展开所有支持 ...
- asp.net DropDownList实现二级联动效果
1.在aspx页面中,拖入两个DroDownList控件,代码如下: <div> <asp:DropDownList ID="s1" runat=" ...
- [Asp.net]DropDownList改变默认选中项的两种方式
引言 其实是不想总结这方面的内容,发现太简单了,可是在这上面也栽了跟头.所以还是记录一下吧,算是提醒自己,不要太看不起太基础的东西,有这种心理,是会载大跟头的. 一个例子 这里模拟一下最常用的一个例子 ...
随机推荐
- freemark 判断是否为空 是否存在
<!--1\---><!--判断aaa是否不为空,eclipse插件老报错.---><#if aaa??> ${aaa}</#if><!--2\ ...
- C++Primer STL算法
//1.概览: // A:beg和end是表示元素范围的迭代器. // B:beg2是表示第二个输入序列开始位置的迭代器.end2表示第二个序列的末尾位置,若没有end2,则假定beg2表示的序列至少 ...
- hdu 2892 Area
http://acm.hdu.edu.cn/showproblem.php?pid=2892 解题思路: 求多边形与圆的相交的面积是多少. 以圆心为顶点,将多边形划分为n个三角形. 接下来就求出每个三 ...
- 点的双联通+二分图的判定(poj2942)
Knights of the Round Table Time Limit: 7000MS Memory Limit: 65536K Total Submissions: 10804 Acce ...
- PHP isset()与empty()的使用区别详解
通过对PHP语言的学习,应该知道它是基于函数的一款HTML脚本语言.庞大的函数库支持着PHP语言功能的实现.下面我们为大家介绍有关PHP函数isset()与empty()的相关用法. PHP的is ...
- yii添加行的增删改查
效果图: 控制器: <?phpnamespace backend\controllers;use Yii;use yii\web\Controller;use backend\models\Zh ...
- POJ 1286 Necklace of Beads(Polya原理)
Description Beads of red, blue or green colors are connected together into a circular necklace of n ...
- 由linux下的多进程编程引发的关于进程间隔离的思考
源代码放到了三个文件中: #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include & ...
- form 表单jquery验证插件使用
第一部分:表单样式 <form action="#" method="post" id="regist"> <tabl ...
- .net web弹出对话框
Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('请输入 ...