Viewstate

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
 
V

vMike

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
 
B

Brock Allen

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.
 
V

vMike

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.
 
V

VK

Thanks for the input. I will store the sortexpression in
an additional property.

Regards
 

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

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,142
Latest member
arinsharma
Top