Viewstate

  • Thread starter Thread starter VK
  • Start date Start date
V

VK

Hello,

I have created a datalist control which I derived from
the datalist control. Now I also implemented sorting for
this datalist. In my webform when the user clicks the
header, then I simply store the SortExpression in the
viewstate and do the sorting then. Now I would like to
have some kind of indication for the sorting, so that the
user can see which column is sorted and in which
direction. I would like to do that in the component. I
thought that the best event for that would be
ItemDataBound. I am trying to access the SortExpression
from the ViewState there, but it is always empty. I also
tried ItemCreated , but no success.

Can anybody help?

Thanks
 
VK said:
Hello,

I have created a datalist control which I derived from
the datalist control. Now I also implemented sorting for
this datalist. In my webform when the user clicks the
header, then I simply store the SortExpression in the
viewstate and do the sorting then. Now I would like to
have some kind of indication for the sorting, so that the
user can see which column is sorted and in which
direction. I would like to do that in the component. I
thought that the best event for that would be
ItemDataBound. I am trying to access the SortExpression
from the ViewState there, but it is always empty. I also
tried ItemCreated , but no success.

Can anybody help?

Thanks

Clip from the help doc.... In general, you do not need to call this method.
However, if you store custom information in view state, you could override
this method to do so....

Protected Overrides Function SaveViewState() As Object
Return MyBase.SaveViewState()
End Function

Protected Overrides Sub LoadViewState(savedState As Object)
If Not (savedState Is Nothing) Then
MyBase.LoadViewState(savedState)
End If
End Sub
 
When DataBind is called, the base class clears out all the ViewState for
your control. So you could either take control over Save/Loading of ViewState
by overiding those methods and then adding in your own extra bit of info,
or you can override DataBind, call the base, and then store your SortExpression
back in after. In either case, you're going to have to store the SortExpression
in a field for some processing on your page while the ViewState gets clobbered.

-Brock
DevelopMentor
http://staff.develop.com/ballen
 
Clip from the help doc.... In general, you do not need to call this method.
However, if you store custom information in view state, you could override
this method to do so....

Protected Overrides Function SaveViewState() As Object
Return MyBase.SaveViewState()
End Function

Protected Overrides Sub LoadViewState(savedState As Object)
If Not (savedState Is Nothing) Then
MyBase.LoadViewState(savedState)
End If
End Sub
Sorry, I don't think this will solve you problem. There must be something
else. This method is used in certain other situations.
 
Back
Top