【问题标题】:How to set Radio button property corresponding to the Database value如何设置与数据库值对应的单选按钮属性
【发布时间】:2011-03-28 07:12:48
【问题描述】:

我有一个应用程序,因此我的字段与 gridview 绑定,其中我将有一个字段名可能已更新,这在我的表中可能是是/否。当我绑定我的值时,我想在网格中显示一个单选按钮,就像我将在该字段中有 2 个单选框,即是或否。如果在我的数据库字段中,如果它保存为否,我想向用户显示没有选中单选按钮,如果是,我想显示替代项

【问题讨论】:

    标签: c# .net asp.net gridview radio-button


    【解决方案1】:

    你需要使用gridview rowdatabound事件

    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 
        }
    }
    

    【讨论】:

    • 我怎样才能将它设置为选中否和是的你能告诉我
    猜你喜欢
    • 2016-06-28
    • 2014-08-23
    • 2022-10-17
    • 2013-07-28
    • 2018-05-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-04-23
    相关资源
    最近更新 更多