【问题标题】:Disable RadioButton inside Repeater Item禁用中继器项内的 RadioButton
【发布时间】:2013-10-10 04:58:21
【问题描述】:

我有以下包含单选按钮的中继器:

<asp:Repeater ID="RptLeaveRequests" runat="server" 
        onitemdatabound="RptLeaveRequests_ItemDataBound">
<ItemTemplate>
    <table id="tableItem" runat="server">
    //displaying other data which is not relevant to qeustion
                <td style="50px">
                    <asp:RadioButtonList ID="rbtVerified" runat="server" >
                        <asp:ListItem Value="1">Accept</asp:ListItem>
                        <asp:ListItem Value="2">Reject</asp:ListItem>
                    </asp:RadioButtonList>
                </td>
                <td>
                    <asp:TextBox ID="txtNotes" runat="server" ></asp:TextBox>
                </td>
            </tr>
    </table>
</ItemTemplate>
</asp:Repeater>

现在正在从代码中的方法填充数据:

DataTable dt = new LeaveLogic().GetManagerUnverifiedLeaveRequests(Convert.ToInt32(Context.User.Identity.Name));
                if (dt.Rows.Count > 0)
                {
                    RptLeaveRequests.DataSource = dt;
                    RptLeaveRequests.DataBind();
                }

如果从名为 ReadOnly 的数据库(和 DataTable dt)中检索到的记录为真,如何遍历每一行并禁用/隐藏单选按钮?

这应该放在Repeater_ItemDataBound 方法中还是其他地方?

【问题讨论】:

    标签: asp.net radio-button repeater


    【解决方案1】:

    你可以这样使用

    <asp:RadioButtonList ID="rbtVerified" runat="server" Enabled='<%#Eval("booleanValue") %>' >
    

    但您需要确保您将单选按钮列表与布尔值绑定。

    【讨论】:

      猜你喜欢
      • 2010-09-22
      • 2016-10-07
      • 2014-10-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-04-03
      • 1970-01-01
      相关资源
      最近更新 更多