0

I have one gridview which checkbox,

 <asp:GridView ID="GriduwgDocuments" AutoGenerateColumns="False" runat="server"
            EnablePersistedSelection="true" AllowPaging="True" AllowSorting="True" GridLines="None"
            Width="960px"  PageSize="25">
                           <PagerSettings Position="Top"></PagerSettings>
            <RowStyle CssClass="result-grid-row" />
            <AlternatingRowStyle CssClass="result-grid-row-alternate" />
            <SelectedRowStyle CssClass="result-grid-row-selected" />
            <HeaderStyle Height="20px" CssClass="result-grid-header" />
             <Columns>
             <asp:TemplateField >
     <ItemTemplate>
       <asp:CheckBox ID="chkBxSelect" runat="server"  OnCheckedChanged="cbRowChanged_CheckedChanged" />  
     </ItemTemplate>

  </asp:TemplateField>

and button,

  <asp:Button ID="btnGetDocs" runat="server" Text="Download Selected Docs" 
                                                CssClass="Button" 
                                                Width="140px" Enabled="False" />

What I am trying to do is , when page load first time my button is Enabled="False" and as soon as client checked any checkbox of grid, my button should be Enabled="true" . I mean clickable.

on OnCheckedChanged of checkbox ,its goes to behind the code cbRowChanged_CheckedChanged.

please advice !!

1
  • What is inside cbRowChanged_CheckedChanged and what is not working? Commented Jan 25, 2018 at 21:05

1 Answer 1

2

Do this via javascript. If you have jQuery available, it might look like this:

$('#GriduwgDocuments input:checkbox').change(
    function(){
        if ($(this).is(':checked')) {
            $('#btnGetDocs').attr("disabled", false);
        }
    });

Of course, you should also verify this server-side when the form is submitted., and depending on what client id mode you use on the page you may need to get the generated client id.

Sign up to request clarification or add additional context in comments.

4 Comments

this is exactly I am trying to do in JavaScript.
i am getting "JavaScript runtime error: Object doesn't support property or method 'prop'" error .
$('#btnGetDocs').attr("disabled", false); just work as expected.
Fixed, thanks, though my understanding is jQuery 1.6 and later should use .prop()

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.