您好,欢迎来到风匀科技网。
搜索
您的当前位置:首页ASP.NET DropDownList控件的使用方法

ASP.NET DropDownList控件的使用方法

来源:风匀科技网


1. 数据绑定

代码如下:


this.DropDownList1.DataSource = CategoryManager.getCategories();
DropDownList1.DataValueField = "id";//用来设置下拉列表选中的 Value 值
DropDownList1.DataTextField = "name";//为下拉列表选项显示的值
DropDownList1.DataBind();

2.读取数据
代码如下:


int categoryId = int.Parse(this.DropDownList1.SelectedItem.Value);//获取下拉列表中选中的值

Copyright © 2019- fengyunshixun.com.cn 版权所有

违法及侵权请联系:TEL:199 18 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务