位置 :  首页 / 博客 / 学无止境

ASP.NET获取DropDownList和CheckBoxList的值

发布人: 发布时间:2019/01/05 访问量:1594
Page_Load中获取CheckBoxList值
ListItem li = radsex.Items.FindByValue(model.sex.ToString());
if (li != null)
{
li.Selected = true;
}
Page_Load中获取DropDownList值
li = ddlprovince.Items.FindByValue(model.province);
ddlprovince.ClearSelection();
if (li != null)
{
li.Selected = true;
}
BindDDLCity();

Page_Load中获取DropDownList 省份ddlprovince的值 AutoPostBack="True"
ddlprovince.DataSource = new DAL.ProvinceDAL().GetList("");
ddlprovince.DataTextField = "province";
ddlprovince.DataValueField = "provinceid";
ddlprovince.DataBind();

双击省份ddl 绑定城市ddl BindDDLCity
ddlcity.DataSource = new DAL.CityDAL().GetList("father='" + ddlprovince.SelectedValue + "'");
ddlcity.DataTextField = "city";
ddlcity.DataValueField = "cityid";
ddlcity.DataBind();

Uitlity.Tool.SetDropDownListValue("ddltype",model.id.Tostring(),"value")