当前位置: 代码迷 >> ASP.NET >> 怎么根据数据库内容,页面初始化时候设定RadioButtonList和DropDownList1的值呢
  详细解决方案

怎么根据数据库内容,页面初始化时候设定RadioButtonList和DropDownList1的值呢

热度:5137   发布时间:2013-02-25 00:00:00.0
如何根据数据库内容,页面初始化时候设定RadioButtonList和DropDownList1的值呢?
比如   DropDownList   中选择的是河北。查看时候DropDownList也显示河北
同样
RadioButtonList   在用户录入时候选择是男,查看时候   也选中“男”

------解决方案--------------------------------------------------------
pageload()
中做BIND数据操作,然后指定想显示的ITEMINDEX
------解决方案--------------------------------------------------------
this.ddlType.SelectedValue=((ListItem)ddlType.Items.FindByText(temp)).Value;

this.ddlType.SelectedIndex=this.ddlType.Items.IndexOf(this.ddlType.Items.FindByText( "河北 ")); this.ddlType.SelectedIndex=this.ddlType.Items.IndexOf(this.ddlType.Items.FindByValue(this.TradeType.ToString()));