473,322 Members | 1,504 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

How to clear a command after it's done

I have a button to insert a row in a gridview, when it's clicked, the RowCommand is triggered, and a new row is inserted to the database. The insertion goes very well, but problem is when refreshing the page, it seems the 'insert' was saved, and so the program is still trying to do another invalid insert.
If the new insert is already deleted from the database, it was added again when refreshing the page.
So how can I, after the insert (or any commands) is done, clear the commandName of the EventArg (see below), and all the inputParameters associate with it? Thanks a million for any helps!!
Expand|Select|Wrap|Line Numbers
  1. protected void gvStudentsAndProjects_RowCommand(object sender, GridViewCommandEventArgs e)
  2.     {
  3.         if (e.CommandName.CompareTo ("Insert")==0 && Page.IsValid)
  4.         {
  5.             OdsStudentsAndProjects.Insert();
  6.             databind();
  7.         }
  8.     }
  9.  
Oct 31 '07 #1
2 851
I was facing the same problem, i posted my problem last week on the .net forum but unfortunately i got no reply. So after doing lots of search i found the best solution to this problem is to do a Response.Redirect to the same page. The only problem of doing redirect is that the state of the page is lost.

By the way you cant clear the command as it is readonly property.
Nov 1 '07 #2
I was facing the same problem, i posted my problem last week on the .net forum but unfortunately i got no reply. So after doing lots of search i found the best solution to this problem is to do a Response.Redirect to the same page. The only problem of doing redirect is that the state of the page is lost.

By the way you cant clear the command as it is readonly property.
Thank you, Saad. Your solution sounds a good idea for me.
Nov 1 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: jcollins | last post by:
Is there a command in Python to clear the screen? That is without writing multiple blank lines. Thanks. Jim C
6
by: Maxd out | last post by:
Hi I'm wondering if you can clear a monitor display cout that asks for something after it's been read in by cin e.g; cout <<"Enter number" <<endl; If so how can it be done?
1
by: manoj.bhosale | last post by:
Hello Friends, I am Manoj, just started learning c++ on linux. In 'C' or 'C++' program on DOS/Windows we use clrscr(); with #include<conio.h> file included. In linux conio.h file is not exist,...
14
by: Alan Silver | last post by:
Hello, I have spent ages trawling through Google, looking for information about global functions in ASP.NET and I'm still not clear about the best way to go about this (or not). I am writing...
1
by: scottin | last post by:
I setup the dataset, which is the datasource for a datagrid. When I originally fill the dataset, the data is loaded into dataset.tables(0). (dataset.tables(0).rows.count = 8) Then, if a row...
22
by: mp | last post by:
i have a python program which attempts to call 'cls' but fails: sh: line 1: cls: command not found i tried creating an alias from cls to clear in .profile, .cshrc, and /etc/profile, but none...
4
by: jois.de.vivre | last post by:
I'm having some unexpected behavior regarding clear() in the map container. I have the following code: /// --- begin code #include <map> #include <vector> #include <iostream> #include...
7
by: polecat | last post by:
Im new to .NET and I am having probs with this Every time I reload the form the same data is repeated again.... Done reading on msdn and another forum cant figure out why the...
7
by: CapnBearbossa | last post by:
hi all, forgive me , but the RTFM and Google search approaches are not yielding an answer on this question. I need to know if there's a top level python interpreter command that clears all user...
1
by: sganeshsvk | last post by:
i want to clear the screen command prompt for mysql in windows XP... In linux we use (CTRL + L) for clear the screen in mysql prompt.... i already use this command ( \c ) then ( \! clear ) for...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.