GridView adds duplicate row on Page refresh
-
Hi, I have a GridView with a FormView on its EmptyDataTemplate so that user can insert a row initially. I provide controls on Footer so that user can add rows from within the GridView. I also use inline editing and deletion. Datasource is SqlDataSource. Problem is that when I refresh the page duplicate row is added with previous data in the grid footer controls. I tried many ways to avoid it, I tried
Page.IsValid
(it returns true!), I tried to check for
e.Command == "insert"
, that too is correct. Even the
TextBox.Text
has values though it is empty after a manual insert operation. What am I doing wrong here? Regards, Blumen
“Last night I lay in bed looking up at the stars in the sky and I thought to myself, where the heck is the ceiling.”
-
Hi, I have a GridView with a FormView on its EmptyDataTemplate so that user can insert a row initially. I provide controls on Footer so that user can add rows from within the GridView. I also use inline editing and deletion. Datasource is SqlDataSource. Problem is that when I refresh the page duplicate row is added with previous data in the grid footer controls. I tried many ways to avoid it, I tried
Page.IsValid
(it returns true!), I tried to check for
e.Command == "insert"
, that too is correct. Even the
TextBox.Text
has values though it is empty after a manual insert operation. What am I doing wrong here? Regards, Blumen
“Last night I lay in bed looking up at the stars in the sky and I thought to myself, where the heck is the ceiling.”
In the Insert command event,write the code which validates the data to check for the duplicates and then insert into the SqlDataSource. Update the gridview only if the transaction is successful.
"Don't worry if it doesn't work right. If everything did, you'd be out of a job." (Mosher's Law of Software Engineering)
-
In the Insert command event,write the code which validates the data to check for the duplicates and then insert into the SqlDataSource. Update the gridview only if the transaction is successful.
"Don't worry if it doesn't work right. If everything did, you'd be out of a job." (Mosher's Law of Software Engineering)
-
Thank you, I appreciate that. I was looking for less-code approach :)
“Last night I lay in bed looking up at the stars in the sky and I thought to myself, where the heck is the ceiling.”
Ok! Find it out and let me know :)
"Don't worry if it doesn't work right. If everything did, you'd be out of a job." (Mosher's Law of Software Engineering)