Advertisements

Where do you specify EnableViewState=false? For the whole page in the <%@
Page...> directive? You should do it only for the grid and other components
you want the ViewState to be off.

Eliyahu

"sonic" <> wrote in message
news:...
> Hi,
> I am experimenting with different viewstate management ideas for large
> datagrids, and found a microsoft suggestion to turn it off, and only
> store relevant information by manually accessing viewstate. as per some
> helpful suggestins in MSDN "Common DataGrid Mistakes"
>http://msdn.microsoft.com/library/d...dnaspp/html/aspnet-commondatagridmistakes.asp
>
> they suggest disabling datagrid viewstate and adding selective
> information to it i.e. ViewState["editindex"] = this.EditItemIndex etc.
>
> the problem i encountered is, when i set EnableViewState=false, nothing
> gets saved there, even though i explicitly save / load viewstate
> variables.
>
> Any advice in having it disabled but still using it ?
>

Advertisements

I have the same problem. When I disable datagrid viewstate, it skips the
datagrid1__SelectedIndexChanged routine entirely.

George

"Eliyahu Goldin" wrote:
> Where do you specify EnableViewState=false? For the whole page in the <%@
> Page...> directive? You should do it only for the grid and other components
> you want the ViewState to be off.
>
> Eliyahu
>
> "sonic" <> wrote in message
> news:...
> > Hi,
> > I am experimenting with different viewstate management ideas for large
> > datagrids, and found a microsoft suggestion to turn it off, and only
> > store relevant information by manually accessing viewstate. as per some
> > helpful suggestins in MSDN "Common DataGrid Mistakes"
> >
> http://msdn.microsoft.com/library/d...dnaspp/html/aspnet-commondatagridmistakes.asp
> >
> > they suggest disabling datagrid viewstate and adding selective
> > information to it i.e. ViewState["editindex"] = this.EditItemIndex etc.
> >
> > the problem i encountered is, when i set EnableViewState=false, nothing
> > gets saved there, even though i explicitly save / load viewstate
> > variables.
> >
> > Any advice in having it disabled but still using it ?
> >
>
>
>

"George" <> wrote in message
news:...
>I have the same problem. When I disable datagrid viewstate, it skips the
> datagrid1__SelectedIndexChanged routine entirely.
>
> George
>
> "Eliyahu Goldin" wrote:
>
>> Where do you specify EnableViewState=false? For the whole page in the <%@
>> Page...> directive? You should do it only for the grid and other
>> components
>> you want the ViewState to be off.
>>
>> Eliyahu
>>
>> "sonic" <> wrote in message
>> news:...
>> > Hi,
>> > I am experimenting with different viewstate management ideas for large
>> > datagrids, and found a microsoft suggestion to turn it off, and only
>> > store relevant information by manually accessing viewstate. as per some
>> > helpful suggestins in MSDN "Common DataGrid Mistakes"
>> >
>> http://msdn.microsoft.com/library/d...dnaspp/html/aspnet-commondatagridmistakes.asp
>> >
>> > they suggest disabling datagrid viewstate and adding selective
>> > information to it i.e. ViewState["editindex"] = this.EditItemIndex etc.
>> >
>> > the problem i encountered is, when i set EnableViewState=false, nothing
>> > gets saved there, even though i explicitly save / load viewstate
>> > variables.
>> >
>> > Any advice in having it disabled but still using it ?
>> >
>>
>>
>>
Try reloading the datagrid on page_init or page_load even during postback.
Mike

"George" <> wrote in message
news:...
> Thanks vMike. Probably that's the only way to databind the datagrid
> everytime. But how do I know what is the new page selection, or the sort
> column, if I databind in the Page_Load?
>
> George
>
> "vMike" wrote:
>
> >
> > "George" <> wrote in message
> > news:...
> > >I have the same problem. When I disable datagrid viewstate, it skips
the
> > > datagrid1__SelectedIndexChanged routine entirely.
> > >
> > > George
> > >
> > > "Eliyahu Goldin" wrote:
> > >
> > >> Where do you specify EnableViewState=false? For the whole page in the
<%@
> > >> Page...> directive? You should do it only for the grid and other
> > >> components
> > >> you want the ViewState to be off.
> > >>
> > >> Eliyahu
> > >>
> > >> "sonic" <> wrote in message
> > >> news:...
> > >> > Hi,
> > >> > I am experimenting with different viewstate management ideas for
large
> > >> > datagrids, and found a microsoft suggestion to turn it off, and
only
> > >> > store relevant information by manually accessing viewstate. as per
some
> > >> > helpful suggestins in MSDN "Common DataGrid Mistakes"
> > >> >
> > >>http://msdn.microsoft.com/library/d...dnaspp/html/aspnet-commondatagridmistakes.asp
> > >> >
> > >> > they suggest disabling datagrid viewstate and adding selective
> > >> > information to it i.e. ViewState["editindex"] = this.EditItemIndex
etc.
> > >> >
> > >> > the problem i encountered is, when i set EnableViewState=false,
nothing
> > >> > gets saved there, even though i explicitly save / load viewstate
> > >> > variables.
> > >> >
> > >> > Any advice in having it disabled but still using it ?
> > >> >
> > >>
> > >>
> > >>
> > Try reloading the datagrid on page_init or page_load even during
postback.
> > Mike
> >
> >
> >
In general, if the datagrid is user specific you may need to maintain
viewstate or it will go back to its original state. The only other choice is
to maintain some hidden fields or other smaller items in viewstate that will
enable you to recreate the datagrid in the state that the user had at the
time of postback. IMHO viewstate is used to maintain the state of controls
that are specific to one user as opposed to any user.

Share This Page

Welcome to The Coding Forums!

Welcome to the Coding Forums, the place to chat about anything related to programming and coding languages.

Please join our friendly community by clicking the button below - it only takes a few seconds and is totally free. You'll be able to ask questions about coding or chat with the community and help others.
Sign up now!