Click here to Skip to main content
15,896,477 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi all,

I have button in the grid view. I want to pass another column value(string type) to javascript function in button click event.


XML
<div>
        <asp:GridView ID="gvExample" runat="server" DataSourceID="dataSource1" AutoGenerateColumns="false">
            <Columns>
                <asp:TemplateField>
                    <ItemTemplate>
                        <asp:Label ID="lblId" runat="server" Text='<%#Bind("Id") %>'></asp:Label>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField>
                    <ItemTemplate>
                        <asp:Label ID="lblFirstName" runat="server" Text='<%# Bind("FirstName") %>'></asp:Label>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField>
                    <ItemTemplate>
                        <asp:Button ID="btnId" runat="server" OnClientClick='<%# "javascript:return funGet(this)" %>' />
                    </ItemTemplate>
                </asp:TemplateField>
            </Columns>
        </asp:GridView>
        <asp:SqlDataSource ID="dataSource1" runat="server" ConnectionString="Data Source=172.16.36.224;Initial Catalog=DBTraining;User ID=pboas;Password=pa55w0rd!;Asynchronous Processing=true"
            SelectCommand="select * from RegistrationFormsreenu" DeleteCommand="delete from RegistrationFormsreenu where Id=@Id"
            UpdateCommand="update RegistrationFormsreenu set [FirstName]=@FirstName,[LastName]=@lastname,DateofBirth=@DateofBirth, Address=@Address where Id=@Id">
        </asp:SqlDataSource>
    </div>
Posted

C#
OnClientClick='<%# string.Format("javascript:return fnSelectedLocationList(\"{0},{1},{2},{3},{4}\")", Eval("Location"),Eval("Version"),Eval("Lot"),Eval("Quantity"),Eval("WKOLineNumber")) %>'
 
Share this answer
 
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900