Click here to Skip to main content
15,905,420 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all,
I need to pass gridview cell value from a gridview row to a javascript function on button click .I have tried various ways.However its not working .Any help will be really appreciated.Thanks in advance.

What I have tried:

This is my Gridview Button code:

<asp:TemplateField ItemStyle-Width="20px" HeaderText="" ItemStyle-HorizontalAlign="Center">
                                                    <ItemTemplate>
                                                    <asp:Button ID="btnview" runat="server" Text="View Detail" OnClientClick='<%#String.Format("return openPopup({0},')", Eval("IN028_01")) %>'>
                                                          </asp:Button>  
                                                         
                                                    </ItemTemplate>
                                                    <ItemStyle HorizontalAlign="Center" Width="20px" />
                                                </asp:TemplateField>



This is my javascript function:
function openPopup(id) {

            

            window.open("A1000603.aspx?cid=" + id , "_blank", "WIDTH=1080,HEIGHT=790,scrollbars=no, menubar=no,resizable=yes,directories=no,location=no");

        }
Posted
Updated 28-Dec-17 18:47pm

1 solution

try
<asp:Button ID="btnview" runat="server" Text="View Detail"
                         OnClientClick='<%# Eval("IN028_01","return openPopup({0})") %>'></asp:Button>
 
Share this answer
 
Comments
Member 12926744 29-Dec-17 1:03am    
Still its not working.Is there any problem with my javascript.The value is not passing to the script.
Karthik_Mahalingam 29-Dec-17 2:03am    
is this a column name?
IN028_01
Member 12926744 29-Dec-17 2:11am    
Its a datafield value of gridview.
Karthik_Mahalingam 29-Dec-17 2:13am    
what is the column name associated to it?
Member 12926744 29-Dec-17 2:14am    
<asp:BoundField DataField="IN028_01" HeaderText="Cl Ref.No"
ItemStyle-HorizontalAlign="Center" ItemStyle-Width="70px"
SortExpression="IN028_01" NullDisplayText="-" >
<ItemStyle HorizontalAlign="Center" Width="70px" />

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