ASP.NET DropDownList ASP.NET DropDownList控件如何使用

软件发布|下载排行|最新软件

当前位置:首页IT学院IT技术

ASP.NET DropDownList ASP.NET DropDownList控件如何使用

  2021-03-18 我要评论
想了解ASP.NET DropDownList控件怎样使用的相关内容吗,在本文为您仔细讲解ASP.NET DropDownList的相关知识和一些Code实例,欢迎阅读和指正,我们先划重点: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 2022 版权所有 软件发布 访问手机版

声明:所有软件和文章来自软件开发商或者作者 如有异议 请与本站联系 联系我们