0

我正在尝试检查checkboxdataset因为我在数据集中有值就像,

USERNAME     Permissions
Charles     
John         Insert, View
Tom          View

我将如何检查我尝试过的复选框

<asp:CheckBox ID="ChkView" Checked='<%#bool.Parse(Eval("permissions").ToString() == "View" ? "True": "False") %>' runat="server" />View
            <asp:CheckBox ID="ChkInsert" Checked='<%#bool.Parse (Eval("permissions").ToString() == "Insert" ? "True": "False") %>' runat="server" />Insert
            <asp:CheckBox ID="ChkUpdate" Checked='<%#bool.Parse (Eval("permissions").ToString() == "Update" ? "True": "False") %>' runat="server" />Update
            <asp:CheckBox ID="ChkDelete" Checked='<%#bool.Parse (Eval("permissions").ToString() == "Delete" ? "True": "False") %>' runat="server" />Delete

但是权限具有逗号的价值,我们将如何拆分它

希望你的建议

谢谢

4

1 回答 1

1

您可以使用包含而不是 ==

<asp:CheckBox ID="ChkView" Checked='<%#bool.Parse(Eval("permissions").ToString().Contains("View") ? "True": "False") %>' runat="server" />View
            <asp:CheckBox ID="ChkInsert" Checked='<%#bool.Parse (Eval("permissions").ToString().Contains("Insert") ? "True": "False") %>' runat="server" />Insert
            <asp:CheckBox ID="ChkUpdate" Checked='<%#bool.Parse (Eval("permissions").ToString().Contains("Update") ? "True": "False") %>' runat="server" />Update
            <asp:CheckBox ID="ChkDelete" Checked='<%#bool.Parse (Eval("permissions").ToString().Contains("Delete") ? "True": "False") %>' runat="server" />Delete
于 2013-05-14T10:54:07.410 回答