GridView RowComand event Issue

J

J Li

In the footer of the gridview, I have a dropdown and a "Add" button set up,
so I can add new rows to the gridview. The "Add" button has CommandName of
"ADD", so I use that in the GridView1_RowCommand to check if (e.CommandName
== "ADD") before I add the row.

Everything works fine except, after adding a row, then I hit the refresh
button in the browser, another row got added because the commandname in the
RowCommand Event is still "ADD".
 
K

kan

hai J li..
wats ur problem tell me exactly Li.. u need to refresh the page
when add is clicked or ?
 
R

RBM

J said:
In the footer of the gridview, I have a dropdown and a "Add" button set up,
so I can add new rows to the gridview. The "Add" button has CommandName of
"ADD", so I use that in the GridView1_RowCommand to check if (e.CommandName
== "ADD") before I add the row.

Everything works fine except, after adding a row, then I hit the refresh
button in the browser, another row got added because the commandname in the
RowCommand Event is still "ADD".

What kind of browser are you using? You should get a warning you are
doing a post request in most browsers.

For a work around you could set your rowcommand to an other string
after the execution of the method. This will be kind of:
if (e.CommandName == "ADD")
{
// your code
}
e.CommandName = "Cancel";
 

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

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,681
Members
48,796
Latest member
Greg L.

Latest Threads

Top