G
Guest
My gridview Delete command works until I install a confirm prompt as follows,
then it does nothing.
Any suggestions would be appreciated!
protected void MyGridView_RowCreated( object sender, GridViewRowEventArgs e
) {
if ( e.Row.RowType == DataControlRowType.DataRow && ( e.Row.RowState ==
DataControlRowState.Normal ||
e.Row.RowState == DataControlRowState.Alternate ) ) {
ImageButton ib = (ImageButton)e.Row.Cells[0].Controls[2];
ib.Attributes.Add( "onClick", "return confirm('Are you sure you wish
to delete this location?' );" );
}
}
My GridView:
<asp:GridView ID="MyListGridView" runat="server" CssClass="waGridView"
width="700px"
AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False"
DataSourceID="LocationListDataSource" DataKeyNames="LocationId"
OnRowCreated="LocationListGridView_RowCreated">
<Columns>
<asp:CommandField
ShowEditButton="True" ButtonType="Image"
EditImageUrl="~/Images/edit.png"
ShowDeleteButton="True" DeleteImageUrl="~/Images/delete.png" />
<asp:BoundField DataField="LocationId" HeaderText="Id"
InsertVisible="False" ReadOnly="True"
ItemStyle-Width="32px" SortExpression="LocationId" />
then it does nothing.
Any suggestions would be appreciated!
protected void MyGridView_RowCreated( object sender, GridViewRowEventArgs e
) {
if ( e.Row.RowType == DataControlRowType.DataRow && ( e.Row.RowState ==
DataControlRowState.Normal ||
e.Row.RowState == DataControlRowState.Alternate ) ) {
ImageButton ib = (ImageButton)e.Row.Cells[0].Controls[2];
ib.Attributes.Add( "onClick", "return confirm('Are you sure you wish
to delete this location?' );" );
}
}
My GridView:
<asp:GridView ID="MyListGridView" runat="server" CssClass="waGridView"
width="700px"
AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False"
DataSourceID="LocationListDataSource" DataKeyNames="LocationId"
OnRowCreated="LocationListGridView_RowCreated">
<Columns>
<asp:CommandField
ShowEditButton="True" ButtonType="Image"
EditImageUrl="~/Images/edit.png"
ShowDeleteButton="True" DeleteImageUrl="~/Images/delete.png" />
<asp:BoundField DataField="LocationId" HeaderText="Id"
InsertVisible="False" ReadOnly="True"
ItemStyle-Width="32px" SortExpression="LocationId" />