By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,749 Members | 1,574 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,749 IT Pros & Developers. It's quick & easy.

Postback, DataBinding, Refresh

P: n/a
Hi -

I've got a couple of pages where a DataList is populated only if(!Postback).
I have buttons in the datagrid that allow for the 'deletion' of items from
that DataList.

The problem is that the deleted items don't disappear on Postback, but only
after a page refresh. I assume this is because the DataList is not
redatabound unless !Postback. However, if I remove the if(!Postback)
statement, the button's 'delete' method doesn't seem to work at all.

How can I fix this? Do I need to disable viewstate on some things, or do
something like move my PopulateDataList() method from Page_Load to
Pre_Render? Thus far I've been forcing a page refresh after the 'delete'
method is run, by doing Response.Redirect(Request.RawUrl), and that works,
but it doesn't seem efficient.

Thanks in advance!

-John
Nov 18 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
"John" <jc*****************@hotmail.com> wrote in message
news:fG****************@news-server.bigpond.net.au...
Hi -

I've got a couple of pages where a DataList is populated only if(!Postback). I have buttons in the datagrid that allow for the 'deletion' of items from
that DataList.

The problem is that the deleted items don't disappear on Postback, but only after a page refresh. I assume this is because the DataList is not
redatabound unless !Postback. However, if I remove the if(!Postback)
statement, the button's 'delete' method doesn't seem to work at all.

How can I fix this? Do I need to disable viewstate on some things, or do
something like move my PopulateDataList() method from Page_Load to
Pre_Render? Thus far I've been forcing a page refresh after the 'delete'
method is run, by doing Response.Redirect(Request.RawUrl), and that works,
but it doesn't seem efficient.


John, you'll need to refresh the data in the grid the same way you did in
"if(!PostBack)".
--
John Saunders
johnwsaundersiii at hotmail
Nov 18 '05 #2

P: n/a
Thanks for the reply!

Just to make sure I understand what you mean - I need to databind again
within the button's 'delete' method after it's made its change to the
database?

Thanks again!

-John

John, you'll need to refresh the data in the grid the same way you did in
"if(!PostBack)".
--
John Saunders
johnwsaundersiii at hotmail

Nov 18 '05 #3

P: n/a
"John" <jc*****************@hotmail.com> wrote in message
news:Hs****************@news-server.bigpond.net.au...
Thanks for the reply!

Just to make sure I understand what you mean - I need to databind again
within the button's 'delete' method after it's made its change to the
database?

Yes, that's correct. You might want to do the same thing on inserts or
updates, except that you might be able to short-circuit the process if you
found it worthwhile.

Are you handline paging and sorting yet? Those are another case when a
DataBind is useful.
--
John Saunders
johnwsaundersiii at hotmail

John, you'll need to refresh the data in the grid the same way you did in "if(!PostBack)".
--
John Saunders
johnwsaundersiii at hotmail


Nov 18 '05 #4

P: n/a
Excellent - thank you very much for your help.

I haven't had to do much with paging or sorting, yet, but will in the near
future (getting stuck into an assignment where they seem to expect us to
learn everything in one go) - that insight will doubtless save me some
head-scratching. Seemed like it would be a common problem for one who has no
idea what they're doing... I guess I just couldn't get my google-searches
right; so I'm glad I'm sorted now.

Thanks again!

-John

"John Saunders" <jo**************@notcoldmail.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Yes, that's correct. You might want to do the same thing on inserts or
updates, except that you might be able to short-circuit the process if you
found it worthwhile.

Are you handline paging and sorting yet? Those are another case when a
DataBind is useful.
--
John Saunders
johnwsaundersiii at hotmail

Nov 18 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.