Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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:

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

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.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...