最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
ASP.NET入门教程
时间:2010-12-27 编辑:简简单单 来源:一聚教程网
1,首先,绑定了数据库教程中的一个“nclass表”
show sourceview sourceprint?1 dataset ds = getdataset("select * from nclass");2 this.combobox1.displaymember = "classname";
3 this.combobox1.valuemember = "classid";
4 this.combobox1.datasource = ds.tables[0];
“displaymember”属性:用自己最通俗的话来说,就是要显示给用户看的,绑定数据库中表“nclass”的“classname”字段;
“valuemember”属性:获取或设置一个属性的值,该值绑定为数据库中表“nclass”的“classid”字段;
dataset ds = getdataset("select * from nclass");
this.combobox1.displaymember = "classname";
this.combobox1.valuemember = "classid";
this.combobox1.datasource = ds.tables[0];
2,测试combobox选中后,相应属性是什么样的值:
show sourceview sourceprint?1 debug.writeline(this.combobox1.selectedindex); 2 3 debug.writeline(this.combobox1.selectedvalue.tostring()); 4 5 debug.writeline(this.combobox1.text); 6 7 debug.writeline(this.combobox1.selecteditem.gettype()); this.combobox1.selectedindex:如果此时选中的是combobox中第一个下拉选项,则该属性是获取当前第一个下拉选项的索引值,我这边索引值为“0”,依次递增;
this.combobox1.selectedvalue:该属性获得的是数据库中表“nclass”的“classid”字段对应的值;
debug.writeline(this.combobox1.selectedindex);
debug.writeline(this.combobox1.selectedvalue.tostring());
debug.writeline(this.combobox1.text);
debug.writeline(this.combobox1.selecteditem.gettype());
this.combobox1.text:该属性获取当前下拉菜单中选定的文本内容;
this.combobox1.selecteditem.gettype():该属性获取当前下拉菜单选择的每一行对象是什么类型
相关文章
- 理解Asp.Net中WebForm的生命周期 06-20
- asp.net中使用母版制作出的页脚效果 05-17
- ASP.NET在使用X509Certificate2出现问题时的一些解决方法 05-16
- ASP.NET 定时器回调方法的重入 04-20
- 剖析Asp.Net Web API路由系统---WebHost部署方式 04-13
- Asp.net用Button打开另一个的frm的教程 12-26