控件RadioButtonList绑定不显示???
为什么在RadioButtonList控件中可以用SelectedValue获取该控件中的值而用该控件绑定数据库中的值时用该属性就不能显示???? --------------------编程问答-------------------- 你是怎么绑定的??? --------------------编程问答--------------------
//获取跳转页面传递的id号
int typeid = Convert.ToInt32(Request.QueryString["roomTypeid"]);
RoomType roomType = new RoomType();
roomType = RoomTypeManager.GetALlById(typeid); //根据id号获得对象
//以下是对各个控件的绑定值
this.txtTypeName.Text = roomType.TypeName;
this.txtAddBedPrice.Text = roomType.AddBedPrice.ToString();
this.txtRemark.Text = roomType.Remark;
this.txtTypePrice.Text = roomType.TypePrice.ToString();
this.RadioButtonList1.SelectedValue = roomType.IsAddBed;
你可以看以上的代码 --------------------编程问答-------------------- this.RadioButtonList1.SelectedValue = roomType.IsAddBed;
首先,你这样做的前提是你的RadioButtonList1的数据已经绑定了
如果还没有绑定是选择不到的
一般我建议是这样设置选中项:
this.RadioButtonList1.Items.FindByValue(roomType.IsAddBed).Selected = true;
补充:.NET技术 , ASP.NET