I would like to know how to avoid the same operation from being performed twice after s开发者_如何学Come action has been taken on the gridview.
i.e. on clicking a button in gridview, operations in RowCommand get executed. Then on doing a page refresh, the same thing gets done again.
How can we avoid this?
Thanks!
Could you not just set a flag then check if it's true or not. For example when they press the button the flag is set to false so it executes the commands and sets the flag to true. When they refresh the flag is set to true to it doesn't execute the command.
Could use a hidden label for the flag if needed. Not the nicest solution but it works.
if(flag==false)
{
//RowCommand Operations
flag=true;
}
For the label approach just set the initial label text to "" then
if(myLabel.Text=="")
{
//RowCommand Operations
myLabel.Text="Something Else";
}
精彩评论