0
我想觸發一個javascript來確認刪除該行。在gridview中設置onclientclick後javascript不會觸發rowdatabound
這是的RowDataBound
Private Sub GridSlide_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridSlide.RowDataBound
If e.Row.RowType = DataControlRowType.DataRow Then
DirectCast(e.Row.FindControl("LinkDelete"), LinkButton).Attributes.Add("OnClientClick", "javascript:DeleteSlide('" & Convert.ToString(e.Row.RowIndex) & "')")
End If
End Sub
這是JavaScript
function DeleteSlide(var_row) {
var blnResponse = null;
var strMessage = '';
try {
strMessage = 'Are you sure you want to delete this slide data?';
blnResponse = window.confirm(strMessage);
if (blnResponse) {
__doPostBack('DeleteSlide()', var_row );
}
}
catch (Err) {
alert('DeleteSlide - ' + Err.description);
}
}
但是當我點擊刪除鏈接按鈕時,JavaScript將不會觸發。
有什麼問題?
P.S.我嘗試使用CommandArgument和Container.DataItemIndex但導致了更多的錯誤,所以我最終使用rowdatabound。
在瀏覽器控制檯的任何錯誤? – iJade
nope ...但我找到了解決方案。謝謝! – user2621831