Click here to Skip to main content
15,889,266 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear all

Is this possible to get which row no is clicked of grid views button in JavaScript
I have a button in grid view like this:
JavaScript
 <asp:TemplateField HeaderText="Remove" >                       
 <itemtemplate>
 <asp:ImageButton  ID="removerow" CssClass="btnsmall" ImageUrl="../Images/minus_circle_green.png" Height="20px" Width="20px"  runat="server" OnClientClick="return confirmdelete();"  onclick="removerow_Click"/>
</itemtemplate>
Posted
Updated 23-Sep-11 21:42pm
v3

Have a look at below CodeProject Article.

Using JavaScript To Select GridView Rows
 
Share this answer
 
U can pass the ID of that row or record to javascript function
as
onclick='<%# "functionname(" +Eval("ID") + " );" %>'
 
Share this answer
 
Comments
mayur csharp G 24-Sep-11 5:30am    
i did in this way
OnClientClick="return confirmdelete(this.id)"

function confirmdelete(tid)
{
// alert(tid);
var rowno=tid.split('_');
rowno=rowno[1];

alert(rowno);


}
Hi,
You can use this,
C#
OnClientClick='return confirmdelete("<%# Container.DataItemIndex %>");'

And in the javascript fuction
JavaScript
function confirmdelete(rowno) { alert(rowno); }

Hope this will help
 
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