lorena
Centurion
I am trying to create a class that can be invoked to create a bi-directional sort of any datagrid on the pages of the site I am working on.
This is only the second time I have ever tried this and I am getting errors in the code but I am not sure why.
I want to incorporate ViewState as part of the class.
This is my code:
I included the System.Web in my Project references
This is my error message:
'System.Web.UI.Control.Protected Overridable Overloads ReadOnly Property ViewState() As System.Web.UI.StateBag' is not accessible in this context because it is 'Protected'
It seems like there should be a way to do this so I don't have to keep copying the code each time. I just can't quite figure it out.
This is only the second time I have ever tried this and I am getting errors in the code but I am not sure why.
I want to incorporate ViewState as part of the class.
This is my code:
Visual Basic:
Imports System.Web.UI.Page
Public Class clsSort
Private Property SortExpression() As String
Get
Dim o As Object = ViewState("SortExpression")
If o Is Nothing Then
Return String.Empty
Else
Return o.ToString
End If
End Get
Set(ByVal Value As String)
ViewState("SortExpression") = Value
End Set
End Property
Private Property SortAscending() As Boolean
Get
Dim o As Object = ViewState("SortAscending")
If o Is Nothing Then
Return True
Else
Return Convert.ToBoolean(o)
End If
End Get
Set(ByVal Value As Boolean)
ViewState("SortAscending") = Value
End Set
End Property
End Class
This is my error message:
'System.Web.UI.Control.Protected Overridable Overloads ReadOnly Property ViewState() As System.Web.UI.StateBag' is not accessible in this context because it is 'Protected'
It seems like there should be a way to do this so I don't have to keep copying the code each time. I just can't quite figure it out.