You put it in the wrong place. Right now, you passed it as a parameter to the Url.Action helper, whereas it should be a separate attribute, just as you defined the href attribute:
<a href="@Url.Action("EditBookByID", "Books", new { bookID = item.BookDetailsID, CreatedBy = item.UserID })" onclick="return confirm('Are you sure you want to Edit?')">Edit</a>
By the way, you should consider using helpers for this:
grid.Column("", "", format: @<text> @if(!item.IsBookPublished) { Html.ActionLink( "Edit", "EditBookByID", "Books", new { bookID = @item.BookDetailsID }, new { onclick = "return confirm('Are you sure you want to Edit?')" } ) } </text> )
source share