confirm not working

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" />
 
G

Guest

Try to use RowDataBound instead of RowCreated event
I thinks this should work fine
--
Muhammad Mosa
Software Engineer & Solution Developer
MCT/MCSD.NET
MCTS: .Net 2.0 Web Applications
MCTS: .Net 2.0 Windows Applications
 
G

Guest

I should clarify, the prompt appears, it's just that the delete command
doesn't execute afterwards. If I turn the command fieldinto a templagefield
everything works, I just have to up the control[x] to x+1. I can live with
template fields, just wanted to use the commandfield shortcut.


Thanks.

Muhammad Mosa said:
Try to use RowDataBound instead of RowCreated event
I thinks this should work fine
--
Muhammad Mosa
Software Engineer & Solution Developer
MCT/MCSD.NET
MCTS: .Net 2.0 Web Applications
MCTS: .Net 2.0 Windows Applications


Dabbler said:
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" />
 
K

Kumar Reddi

How are you posting back when the user clicks OK for the delete prompt?

Dabbler said:
I should clarify, the prompt appears, it's just that the delete command
doesn't execute afterwards. If I turn the command fieldinto a
templagefield
everything works, I just have to up the control[x] to x+1. I can live with
template fields, just wanted to use the commandfield shortcut.


Thanks.

Muhammad Mosa said:
Try to use RowDataBound instead of RowCreated event
I thinks this should work fine
--
Muhammad Mosa
Software Engineer & Solution Developer
MCT/MCSD.NET
MCTS: .Net 2.0 Web Applications
MCTS: .Net 2.0 Windows Applications


Dabbler said:
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" />
 
G

Guest

I thought the commandfield would take care of it.

Kumar Reddi said:
How are you posting back when the user clicks OK for the delete prompt?

Dabbler said:
I should clarify, the prompt appears, it's just that the delete command
doesn't execute afterwards. If I turn the command fieldinto a
templagefield
everything works, I just have to up the control[x] to x+1. I can live with
template fields, just wanted to use the commandfield shortcut.


Thanks.

Muhammad Mosa said:
Try to use RowDataBound instead of RowCreated event
I thinks this should work fine
--
Muhammad Mosa
Software Engineer & Solution Developer
MCT/MCSD.NET
MCTS: .Net 2.0 Web Applications
MCTS: .Net 2.0 Windows Applications


:

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" />
 
K

Kumar Reddi

It does .. if the column type is templatefield..Because it uses a
linkbutton to generate the javascript to do the postback. But if you
are using the commandfield.. then you need to write your own javascript
to do the postback
I thought the commandfield would take care of it.

Kumar Reddi said:
How are you posting back when the user clicks OK for the delete prompt?

Dabbler said:
I should clarify, the prompt appears, it's just that the delete command
doesn't execute afterwards. If I turn the command fieldinto a
templagefield
everything works, I just have to up the control[x] to x+1. I can live with
template fields, just wanted to use the commandfield shortcut.


Thanks.

:

Try to use RowDataBound instead of RowCreated event
I thinks this should work fine
--
Muhammad Mosa
Software Engineer & Solution Developer
MCT/MCSD.NET
MCTS: .Net 2.0 Web Applications
MCTS: .Net 2.0 Windows Applications


:

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" />
 
K

Kumar Reddi

It does .. if the column type is templatefield..Because it uses a
linkbutton to generate the javascript to do the postback. But if you
are using the commandfield.. then you need to write your own javascript
to do the postback
I thought the commandfield would take care of it.

Kumar Reddi said:
How are you posting back when the user clicks OK for the delete prompt?

Dabbler said:
I should clarify, the prompt appears, it's just that the delete command
doesn't execute afterwards. If I turn the command fieldinto a
templagefield
everything works, I just have to up the control[x] to x+1. I can live with
template fields, just wanted to use the commandfield shortcut.


Thanks.

:

Try to use RowDataBound instead of RowCreated event
I thinks this should work fine
--
Muhammad Mosa
Software Engineer & Solution Developer
MCT/MCSD.NET
MCTS: .Net 2.0 Web Applications
MCTS: .Net 2.0 Windows Applications


:

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" />
 
G

Guest

that explains why it wasn't working. Thanks Kumar!

Kumar Reddi said:
It does .. if the column type is templatefield..Because it uses a
linkbutton to generate the javascript to do the postback. But if you
are using the commandfield.. then you need to write your own javascript
to do the postback
I thought the commandfield would take care of it.

Kumar Reddi said:
How are you posting back when the user clicks OK for the delete prompt?

I should clarify, the prompt appears, it's just that the delete command
doesn't execute afterwards. If I turn the command fieldinto a
templagefield
everything works, I just have to up the control[x] to x+1. I can live with
template fields, just wanted to use the commandfield shortcut.


Thanks.

:

Try to use RowDataBound instead of RowCreated event
I thinks this should work fine
--
Muhammad Mosa
Software Engineer & Solution Developer
MCT/MCSD.NET
MCTS: .Net 2.0 Web Applications
MCTS: .Net 2.0 Windows Applications


:

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" />
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,998
Messages
2,570,242
Members
46,834
Latest member
vina0631

Latest Threads

Top