assign javascript to linkbutton in datagrid
-
Hello everyone, I have a datagrid in with there is a linkbutton that uses the ItemCommand. When this is clicked, I would like to open a new window and pass the page in the new window the datakeyfield value of the row in which the button was clicked. I've done similar things before with just a link button by itself, along the lines of:
lnkButton.Attributes("onClick") = "window.open('mypage.aspx?RowID=" & intRowID & ")"
But I'm having a hard time figuring out how to adapt that to work from within a datagrid. Any pointers would be greatly appreciated. Thanks in advance! ------------------- abort, retry, fail? -
Hello everyone, I have a datagrid in with there is a linkbutton that uses the ItemCommand. When this is clicked, I would like to open a new window and pass the page in the new window the datakeyfield value of the row in which the button was clicked. I've done similar things before with just a link button by itself, along the lines of:
lnkButton.Attributes("onClick") = "window.open('mypage.aspx?RowID=" & intRowID & ")"
But I'm having a hard time figuring out how to adapt that to work from within a datagrid. Any pointers would be greatly appreciated. Thanks in advance! ------------------- abort, retry, fail?In the datagrid onRowDatabound event, you can use code like the following to find the linkbutton in that row, and then your code above should work the same:
Dim btnLink as LinkButton btnLink = CType(e.Item.FindControl("lnkId"), LinkButton) 'Your code here
-
In the datagrid onRowDatabound event, you can use code like the following to find the linkbutton in that row, and then your code above should work the same:
Dim btnLink as LinkButton btnLink = CType(e.Item.FindControl("lnkId"), LinkButton) 'Your code here