Interesting Problem in DataGrid

  • Thread starter Thread starter Sabari
  • Start date Start date
S

Sabari

Hi,
I have an interesting problem in DataGrid.I have a footer in the
Datagrid which has a textbox and a link button and im adding values to
the grid.Everything seems to work fine until this point.After adding
the value i bind the data to control.now if refresh my browser the
value that i added recently gets added again.This happens everytime i
refresh the same page.

Im adding the values in the grids Itemcommand by finding out the
commandname of the eventargs.Is this the right way to do.Have anyone
come across this.

Regards
Sabari
 
When you click on your 'Add' link button, the EVENTTARGET and EVENTARGUMENT
form items are set to process that command on your page.
Whenver you refresh your page, your browser is sending the previous form
values (including the target and argument) to the server and your page will
simply process the command over again.

You should not refresh/reload ASP.NET pages as the postback process means
that unpredictable results can occur.
 
It may be that each time you postback you are re-adding the new record.
Sometimes you have check whether page is loading for the first time or is it
a postback and take appropriate action. Use Page.IsPostBack property to
find out.

Charlie
 
Philip said:
When you click on your 'Add' link button, the EVENTTARGET and EVENTARGUMENT
form items are set to process that command on your page.
Whenver you refresh your page, your browser is sending the previous form
values (including the target and argument) to the server and your page will
simply process the command over again.

You should not refresh/reload ASP.NET pages as the postback process means
that unpredictable results can occur.

--
Philip Q
Microsoft MVP [ASP.NET]

Sabari said:
Hi,
I have an interesting problem in DataGrid.I have a footer in the
Datagrid which has a textbox and a link button and im adding values to
the grid.Everything seems to work fine until this point.After adding
the value i bind the data to control.now if refresh my browser the
value that i added recently gets added again.This happens everytime i
refresh the same page.

Im adding the values in the grids Itemcommand by finding out the
commandname of the eventargs.Is this the right way to do.Have anyone
come across this.

Regards
Sabari
Thanks Philip and Charlie
I found a way to overcome this problem.I enabled
smartnavigation=true in web.config file and it didnt happen after
that.Once again thx for ur reply.
Regards
Sabari
 
Back
Top