日期:2014-05-19  浏览次数:20397 次

repeater中RadioButtonList问题?
做的是修改页面。。。

从数据库中读出某一行数据,然后修改,

其中比如有 性别 一项,用的是RadioButtonList

怎么让按数据库中的值选定其中一项?

比如数据库中的值是“1”,就自动选定“男”?

------解决方案--------------------
for(int i = 0;i < 数据的行数;i++)
{
CheckBox chbDefault = (CheckBox)this.dgRight.Items[i].Cells[0].FindControl( "chb ");
string attribute = dt_M_Right_Operation.Rows[i][1].ToString();
switch(attribute)
{
case "0 " :
chbDefault.Checked = true;
break;
case "1 " :
chbDefault.Checked = false;
break;
}
}
------解决方案--------------------
for(int i = 0;i < 数据一共的行数.Count;i++)
{
CheckBox chbDefault = (CheckBox)this.dgRight.Items[i].Cells[0].FindControl( "chb ");
string attribute = dt_M_Right_Operation.Rows[i][1].ToString();
switch(attribute)
{
case "0 " :
chbDefault.Checked = true;
break;
case "1 " : chbDefault.Checked = false;
break;
}
}
------解决方案--------------------
楼上正解
------解决方案--------------------
dt_M_Right_Operation.Rows[i][1].ToString(); 
这是从数据集里边 取数据
------解决方案--------------------
如果 你已经知道 你控件的具体位置 就不需要使用循环 查找了 直接使用switch 就可以了
LZ。这只是给你的思路。代码最好自己写一下
------解决方案--------------------
呵呵 没有这么写过。我一般都是邦属性。在后台判断。比较简单
------解决方案--------------------
数据绑定之前,做数据转换.