DropDownList的动态绑定与取默认值

DropDownList1.DataSource = ds; //绑定数据源
DropDownList1.DataTextField = "TypeName"; //文本内容字段
DropDownList1.DataValueField = "TypeId"; //值字段
DropDownList1.DataBind();

ds.Dispose();

 

取默认值

DropDownList1.SelectedValue = year.ToString();

猜你喜欢

转载自blog.csdn.net/ychmj/article/details/9635169