user2176150
user2176150

Reputation: 303

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". I try this method to disable the asp.net checkbox but i can't do this in 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>

Upvotes: 1

Views: 347

Answers (1)

V4Vendetta
V4Vendetta

Reputation: 38200

disabled is something like a boolean attribute when present it implies that the checkbox is to be disabled.

So i guess you should try something like

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

Upvotes: 1

Related Questions