Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Datagrid Control > Gridview keeps adding rows when user causes postback

Thread Tools

Gridview keeps adding rows when user causes postback
Posts: n/a

I have a gridview that has footer with text fields and an "add"
linkbutton. This footer allows the user to add new rows to the

When the user clicks the "add" linkbutton everything works as you
would expect, a record it added to the gridview. The problem is that if
the user causes a post back after doing this (hitting refresh or F5 on
the browser) it will add the same record again and again. e.g. If the
user causes 5 postbacks then 5 duplicate records will be entered.

I can stop this behaviour by disabling viewstate on the gridview, but
then the edit functionality of the gridview stops working properly.

Does anybody have any ideas how I can stop this behaviour?
Here's the code:

Protected Sub lnkAdd_Click(ByVal sender As Object, ByVal e As

If Page.IsValid Then
'Add record in the database
End If

End Sub

Many thanks!


Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
REPOST: Gridview ImageButton causes double postback Tim_Mac ASP .Net 10 05-10-2010 09:18 AM
Hide the Gridview Rows and Header rows in Button click VijayRama ASP .Net 2 10-12-2009 01:58 PM
Button in GridView causes Invalid postback or callback argument dev648237923 ASP .Net Datagrid Control 1 12-28-2006 11:01 PM
Gridview keeps adding rows when user causes postback ASP .Net Datagrid Control 4 10-17-2006 11:55 AM
Postback causes 100=Continue, causes double download prompt? Xavier Osa ASP .Net 0 01-09-2004 11:17 AM