简体   繁体   English

如何禁用GridView中的HTML复选框

[英]How to disable the html checkbox in gridview

i am using the below code to disable the header checkbox whether an item status is "Y". 我正在使用下面的代码来禁用标题复选框,无论项目状态为“ Y”。 I try this method to disable the asp.net checkbox but i can't do this in html chackbox. 我尝试使用此方法禁用asp.net复选框,但无法在html chackbox中执行此操作。 Can anyone help me to do this? 谁能帮我做到这一点?

<asp:TemplateField>
                                    <HeaderTemplate>

                                        <input id="chk_invoice" type="checkbox" onclick="CheckAllinvoice(this)" runat="server" disabled='<%# (Eval("FLD_STATUS").ToString() == "Y") ? "disabled":"enabled" %>' />// ERROR HERE
                                    </HeaderTemplate>
                                    <ItemTemplate>
                                        <asp:CheckBox ID="chkSelect" runat="server" Checked='<%# (bool)(Eval("FLD_PAID").ToString() == "Y") ? false:true %>'
                                            Enabled='<%# (bool)(Eval("FLD_PAID").ToString() == "Y") ? false:true %>' />
                                    </ItemTemplate>
                                    <ItemStyle Width="20px" />
                                </asp:TemplateField>

disabled is something like a boolean attribute when present it implies that the checkbox is to be disabled. disabled )类似于布尔属性(存在时),它意味着该复选框将被禁用。

So i guess you should try something like 所以我想你应该尝试像

.. runat="server" <%# (string)Eval("FLD_STATUS") == "Y" ? "disabled" : "" %> ...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM