1

I am trying to pass row number of the gridview to javascript function when checkbox is clicked. Here is checkbox code inside gridview

<asp:CheckBox ID="chkGroup" runat="server" CommandArgument='<%#Eval("TempFaultID")%>'
OnClick="highlightDescription('+<%# CType(Container,GridViewRow).RowIndex %>+',this.checked);">
</asp:CheckBox>

Here is javascript function which this check box trigger

  <script language="javascript" type="text/javascript">
        function highlightDescription(index, state) {
            alert(index + state);
        }    
  </script>

Here is the output

enter image description here

Problem is that I am unable to get row index. Any help !

1 Answer 1

3

Use the <%# tag over the entire OnClick function:

<asp:CheckBox ID="chkGroup" runat="server"  
OnClick=<%# String.Format("highlightDescription('{0}',this.checked);", CType(Container,GridViewRow).RowIndex) %> >
</asp:CheckBox>
Sign up to request clarification or add additional context in comments.

Comments

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.