GridView Question

G

Gonza

Hi group, i have a question relatred to gridview and postback (i should
probably know this by now, considering i've been working with .net for
a few years now, but baahh). Why could a gridview (regular gridview, no
custom controls inside, bound to a list<custom object>) loose it's
value after a postback. I know that the datasource is not saved in
viewstate, but why are the rows getting cleared????

Thanks in advace

Gonzalo, from Argentina
 
M

Mark Rae

Hi group, i have a question relatred to gridview and postback (i should
probably know this by now, considering i've been working with .net for
a few years now, but baahh). Why could a gridview (regular gridview, no
custom controls inside, bound to a list<custom object>) loose it's
value after a postback. I know that the datasource is not saved in
viewstate, but why are the rows getting cleared????

I imagine because you're populating the GridView in Page_Load, and the code
which fetches the data is surrounded by an IsPostback test...
 
G

Gonza

Yes, i'm doing exactly that, but the question remains: Why should i
rebind the gridview on every postback?

Mark Rae ha escrito:
 
M

Mark Rae

Yes, i'm doing exactly that, but the question remains: Why should i
rebind the gridview on every postback?

Several possibilities:

1) You have turned EnableViewState off on the GridView, or even on the
entire page.

2) The GridView is being created dynamically.

3) The GridView's datasource does not persist across the postback.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top