user545359
user545359

Reputation: 413

How to select the value of a link button in gridview

I have a gridview i am trying to select the value of a link button clicked on a specific row of gridview. below is my code and it is erroring out due to the improper selecting of link button in gridview. Please help me in figuring this out.

on page load this is the error

ASP.Test_aspx does not contain a definition for 'lnkview' and no extension method 'lnkview' accepting a first argument of type 'ASP.createsegment_aspx' could be found (are you missing a using directive or an assembly reference?)

function:

 $(document).ready(function() {

             if($('#<%=this.lnkview.ClientID %>').length){
              $('#this.lnkview').click(function(event) {
                    event.preventDefault();
                    $('#plnClone').dialog({
                        modal: true,
                        width: 550,
                        height: 250,
                        open: function(type, data) {
                            $(this).parent().appendTo("form");
                        }
                    });
                });
            }

            $('#CancelClone').click(function(event) {
                event.preventDefault();
                $('#plnClone').dialog('close');
            });
            //
            if ($('#hfdCloneOffer').val() == "DUPLICATE") {
                $('#plnClone').dialog({
                    modal: true,
                    width: 550,
                    height: 250,
                    open: function(type, data) {
                        $(this).parent().appendTo("form");
                    }
                });
                //
                // Scroll to Page Top
                $('html, body').animate({ scrollTop: '0px' }, 800);
            }

Upvotes: 0

Views: 974

Answers (2)

David MacCrimmon
David MacCrimmon

Reputation: 966

The second line of your code appears to be missing the server tags.

$('#this.lnkview') 

Should become

$('#<%=this.lnkview.ClientID %>')

EDIT Looking at your markup, I don't think you'll be able to do a lnkView.ClientID on it outside of the grid row. Suggest you use put a class on your linkbutton and use it as a selector instead.

MORE EDIT Something like this should work

<asp:LinkButton ID="lnkView" runat="server" Text="View" CausesValidation="false" CssClass="lnkViewClass">

          $('.lnkViewClass').click(function(event) {
                event.preventDefault();
                $('#plnClone').dialog({
                    modal: true,
                    width: 550,
                    height: 250,
                    open: function(type, data) {
                        $(this).parent().appendTo("form");
                    }
                });
            });
        }

Upvotes: 1

Jernej Novak
Jernej Novak

Reputation: 3283

Are you sure that you have element with id 'lnkview' in your aspx code? You are calling this here '#<%=this.lnkview.ClientID %>'

Upvotes: 0

Related Questions