Friday, November 22, 2013

Passing multiple params to Javascript using Eval in asp.net

In this example, it will demonstrate to pass multiple params to Javascript using Eval in ASP.NET
<asp:GridView ID="gvExample" runat="server" AutoGenerateColumns="false">
    <Columns>
        <asp:TemplateField>
            <ItemTemplate>
                <asp:ImageButton runat="server"  CommandName="update"
                    ImageUrl="../../common/images/pencil.gif" ID="Imagebutton1"                OnClientClick='<%# String.Format("EditBankAccount(\"{0}\");", Eval("BankAccountID")) %>'
                    OnClick="ImgBankAccountsDGEdit_Click"></asp:ImageButton>
            </ItemTemplate>
        </asp:TemplateField>
    </Columns>
</asp:GridView>

Syntax:
OnClientClick='<%# String.Format("EditBankAccount(\"{0}\");", Eval("BankAccountID")) %>' 

No comments:

Post a Comment