日期:2014-05-17  浏览次数:20483 次

怎么在当前页面中给引用过来的用户控件中的下拉列表框赋值???
我有一个省市级联的下拉列表用户控件region,我再aa.aspx中引用这个用户控件,通过FindControl可以获取的用户控件region中下拉列表的值,但是,我的aa.aspx是一个修改页面,是从一个数据的列表页点进去的,跳转的时候传了userId进去,在aa.aspx中通过userId获取到user对象,然后我想把user对象中的区域Id赋值给用户控件中的下拉列表,好让它在加载的时候就显示user对象的区域,但是下拉列表的SelectedValue却赋不上值,是怎么回事啊,求高人指点,我的代码是这样写的
DropDownList ddlPro = this.FindControl("regionbar").FindControl("ddlPro") as DropDownList;
DropDownList ddlCity = this.FindControl("regionbar").FindControl("ddlCity") as DropDownList;

ddlCity.SelectedValue=user.regionid.tostring();[code=csharp]
[/code]

但不知为何ddlCity.SelectedValue总是等于空,求高人指点啊!谢谢
DropDownList 用户控件 Web

------解决方案--------------------
like this?
http://www.cnblogs.com/insus/p/3154363.html
http://www.cnblogs.com/insus/archive/2013/03/14/2958871.html
http://www.cnblogs.com/insus/archive/2013/03/05/2943808.html


more user control related:
http://www.cnblogs.com/insus/category/341697.html
------解决方案--------------------
1:首先检查user.regionid.tostring() 是否为空.
2:尝试用 this.drpSort.SelectedItem.Text=user.regionid.tostring();
------解决方案--------------------
ddlCity.SelectedValue=user.regionid.tostring();
你这样赋值是做什么的?

你是增加值吧?!
  ddlCity.Items.Insert( 0, new ListItem(user.regionid.tostring(), "0"));
  ddlCity.SelectedIndex = 0;