How can I customize automatically generated command button, e.g. Delete
?
I want to add a client confirmation on deleting and in the same moment I want this
I would rather recommend using the RowDataBound-event instead of the PreRender-event.
There you can easily have access to your Elements in the specific row. (I think the solution Kelsey posted might have problems with paging (maybe just combined with ajax))
Give the Linkbutton an ID and subsribe to the RowDataBound-event.
void gv_RowDataBound(Object sender, GridViewRowEventArgs e)
{
if(e.Row.RowType == DataControlRowType.DataRow)
{
LinkButton _foo = e.Row.FindControl("LINKBUTTONID") as LinkButton;
if(_foo != null)
{
_foo.OnClientClick = "insert localized text here";
}
}
}