Link to home
Start Free TrialLog in
Avatar of David Rudlin
David RudlinFlag for United Kingdom of Great Britain and Northern Ireland

asked on

How to pass gridview button commandargument to jquery dialog

In an asp.net 3.5 website I have a gridview with an imagebutton on each row. The imagebutton onclick opens a jquery dialog.

How can I pass the imagebutton commandargument to the jquery dialog to be stored there in a hidden field?

Any help would be much appreciated.

Basic code is as follows:

<asp:GridView ID="dgMap" runat="server" AllowSorting="True" AutoGenerateColumns="False"........................

  <asp:TemplateField>
            <ItemTemplate>
                <asp:ImageButton ID="imgbtnViewDialog" runat="server"  ImageAlign="Middle" ImageUrl="~/images/copy.gif" CommandArgument="<%# Container.DataItemIndex %>"
    CssClass="imgbtnViewDialogClass" />
            </ItemTemplate>
        </asp:TemplateField>

...............</asp:GridView>

'CSS to open jquery dialog:

    $('.imgbtnViewDialogClass').click(function () {
              $('#dialog-form').dialog('open');
              return false;
          });
ASKER CERTIFIED SOLUTION
Avatar of jayakrishnabh
jayakrishnabh

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of David Rudlin

ASKER

Excellent answer jayakrishnabh. Thank you so much. I had forgotten about the AlternateText property. I just had to change the AlternateText value to a an item in the DataRow thus:

AlternateText='<%# Eval("eventID")%>'

Thanks again.
However you may want to use .prop rather than attr OR consider using the
data-xxxx notation and then .data("xxxx") to get it
Thank you mplungjan. That is useful additional information.