asp.net - Unable to get selected row index of gridview in javascript -


i have got gridview rows/columns , edit button each row. when edit button clicked, opens popup window textbox , button. want know index of selected row on click of button inside popup. added code so

var table = document.getelementbyid('<%= gvtimeslots.clientid%>'); var row; (var = 1; < table.rows.length; i++) {     row = table.rows[i];     alert(row); } 

but alert gives me "undefined". missing here?

this fix..

function getselectedrow(lnk) {         var row = lnk.parentnode.parentnode;         var rowindex = row.rowindex - 1;         alert("rowindex: " + rowindex);         return false;     } 

i calling function in onclientclick event of link button.

<asp:templatefield headerstyle-horizontalalign="left" headerstyle-width="10%" visible="true">      <itemtemplate>           <asp:linkbutton id="lnkviewtimeslots" runat="server" text="edit" forecolor="blue" onclick="lnkviewtimeslots_click" onclientclick="return getselectedrow(this); javascript:shouldsubmit=true;" causesvalidation="false" style="padding: 0px; margin: 0px;"></asp:linkbutton>      </itemtemplate>  </asp:templatefield> 

Comments

Popular posts from this blog

.htaccess - First slash is removed after domain when entering a webpage in the browser -

Automatically create pages in phpfox -

c# - Farseer ContactListener is not working -