1

I have a normal gridview on asp.net web page... I want to select a row using jquery and then pressing a button to send the id and descripcion columns to a web service...

My question is how can I select the row and get the information I want... all using jquery.

1 Answer 1

3

Try something like

$('#<%=Grid.ClientID %>').delegate('tr', 'click', function(){
    $('#<%=Grid.ClientID %> tr').not(this).removeClass('selectedRow');
    $(this).toggleClass('selectedRow'); 
});

This should enable you to select a single GridView row on click.

After that, for the button control, use the following

$('#<%=Btn.ClientID %>').click(function(){
    alert($('#<%=Grid.ClientID %>').find('tr.selectedRow').html());

    // code to call the webservice using columns from $('#<%=Grid.ClientID %>').find('tr.selectedRow')

    // prevent Button control from causing a postback
    return false;
});
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.