代码之家  ›  专栏  ›  技术社区  ›  Developer

如何设置数据库值对应的单选按钮属性

  •  0
  • Developer  · 技术社区  · 14 年前

    我有一个这样的应用程序,我的字段与gridview绑定在一起,在这些字段中,我将有一个字段名,可能是更新的,在我的表中这可能是Yes/No。当我绑定我的值时,我想在网格中显示一个单选按钮,就像在该字段中有两个单选框,即“是”或“否”。如果在我的数据库字段中,如果保存为“否”,我想向用户显示没有选中的单选按钮,如果是,我想显示备选按钮

    1 回复  |  直到 13 年前
        1
  •  1
  •   Muhammad Akhtar    14 年前

    您需要使用gridview行数据绑定事件

    protected void yourGrid_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            RadioButton rdb= e.Row.FindControl("yourRadioButton") as RadioButton;
            rdb// set here 
        }
    }