源码网商城,靠谱的源码在线交易网站 我的订单 购物车 帮助

源码网商城

ASP.NET DropDownList控件的使用方法

  • 时间:2020-12-29 11:38 编辑: 来源: 阅读:
  • 扫一扫,手机访问
摘要:ASP.NET DropDownList控件的使用方法
1. 数据绑定
[u]复制代码[/u] 代码如下:
this.DropDownList1.DataSource = CategoryManager.getCategories(); DropDownList1.DataValueField = "id";//用来设置下拉列表选中的 Value 值 DropDownList1.DataTextField = "name";//为下拉列表选项显示的值 DropDownList1.DataBind();
2.读取数据
[u]复制代码[/u] 代码如下:
int categoryId = int.Parse(this.DropDownList1.SelectedItem.Value);//获取下拉列表中选中的值
  • 全部评论(0)
联系客服
客服电话:
400-000-3129
微信版

扫一扫进微信版
返回顶部