Connecting Tech Pros Worldwide Forums | Help | Site Map

Interesting Problem in DataGrid

Sabari
Guest
 
Posts: n/a
#1: Nov 16 '05
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

Charlie
Guest
 
Posts: n/a
#2: Nov 16 '05

re: Interesting Problem in DataGrid


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
"Sabari" <sabari.ramasamy@gmail.com> wrote in message
news:1106145537.944426.227990@z14g2000cwz.googlegr oups.com...[color=blue]
> 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
>[/color]


Philip Q [MVP]
Guest
 
Posts: n/a
#3: Nov 16 '05

re: Interesting Problem in DataGrid


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" <sabari.ramasamy@gmail.com> wrote in message
news:1106145537.944426.227990@z14g2000cwz.googlegr oups.com...[color=blue]
> 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
>[/color]


Sabari
Guest
 
Posts: n/a
#4: Nov 16 '05

re: Interesting Problem in DataGrid



Philip Q [MVP] wrote:[color=blue]
> When you click on your 'Add' link button, the EVENTTARGET and[/color]
EVENTARGUMENT[color=blue]
> form items are set to process that command on your page.
> Whenver you refresh your page, your browser is sending the previous[/color]
form[color=blue]
> values (including the target and argument) to the server and your[/color]
page will[color=blue]
> simply process the command over again.
>
> You should not refresh/reload ASP.NET pages as the postback process[/color]
means[color=blue]
> that unpredictable results can occur.
>
> --
> Philip Q
> Microsoft MVP [ASP.NET]
>
> "Sabari" <sabari.ramasamy@gmail.com> wrote in message
> news:1106145537.944426.227990@z14g2000cwz.googlegr oups.com...[color=green]
> > 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[/color][/color]
to[color=blue][color=green]
> > the grid.Everything seems to work fine until this point.After[/color][/color]
adding[color=blue][color=green]
> > 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[/color][/color]
i[color=blue][color=green]
> > 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[/color][/color]
anyone[color=blue][color=green]
> > come across this.
> >
> > Regards
> > Sabari[/color][/color]
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

Closed Thread