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改变默认选中项的两种方式
引言 其实是不想总结这方面的内容,发现太简单了,可是在这上面也栽了跟头.所以还是记录一下吧,算是提醒自己,不要太看不起太基础的东西,有这种心理,是会载大跟头的. 一个例子 这里模拟一下最常用的一个例子 ...
随机推荐
- python自动化运维之路~DAY1
python自动化运维之路~DAY1 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.文件大小单位单位换算 我们一起看一下下面的图: 没错,都是数字,而且这些数字都是二进制的数字 ...
- SQL top order between 一起使用
select * from emp;
- configuring tortoise git and vs code.
Preparation, SSH keygen: $ git config --global user.name "calos" $ git config --global use ...
- How to export a template in Visual Studio?
Create a customize template file: 1.template arguments introduction like: 上图只是其中一部分,更多请查看文后的参考资源 tem ...
- poj: 2159
简单题,看起来很凶 #include <iostream> #include <stdio.h> #include <string> #include <st ...
- springday02-go4
1.复制xml到container/annotation下2.新建Waiter类,构造函数,初始化以及销毁函数3.在Waiter方法体前面加上@Component4.xml中添加组件扫描代码5.tes ...
- SQL —— 视图
1. 为什么使用视图 1) 提高数据的安全型,不同权限的用户可以查看数据的不同. 2) 符合用户日常业务逻辑 2. 什么是视图 视图是一种查看数据库中一个或多个表中的数据的方法. 视图是一种虚拟表. ...
- html5的download下载标签
Html5的下载标签download <a href="files/1.jpg" download="1.jpg">Download</a&g ...
- SQLServer查询速度慢的原因
查询速度慢的原因很多,常见如下几种: 1.没有索引或者没有用到索引(这是查询慢最常见的问题,是程序设计的缺陷) 2.I/O吞吐量小,形成了瓶颈效应. 3.没有创建计算列导致查询不优化. 4.内存 ...
- Android NDK 开发(二) -- 从Hlello World学起【转】
转载请注明出处:http://blog.csdn.net/allen315410/article/details/41805719 上篇文章讲述了Android NDK开发的一些基本概念,以及NDK ...