.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Comparing Enum values in a collection - BC42025: Access of shared member, constant member, enum mem

Posted By:      Posted Date: August 27, 2010    Points: 0   Category :ASP.Net

I am upgrading from asp1.1 to 2.0

I use collection classes to sort data (e.g in datagrids etc)


Enum newsFields
End Enum

Public Overloads Sub Sort(ByVal sortField As newsFields, ByVal isAscending As Boolean)
Select Case sortField
Case newsFields.title

View Complete Post

More Related Resource Links

How to cast integer values as an array of enum values?


Hello all!

I'm working with VS2010 Beta2, ASP.NET and Dynamic Data. I'm using VB but will certainly be happy to receive a C# example if necessary. Laughing

I used a few of Steve's examples (Writing Attributes and Extension Methods for Dynamic Data and Dynamic Data - Hiding Columns in selected PageTemplates) to create a custom property attribute to be applied to a dynamic data column and want it to accept an array of enum values (each value will represent a dynamic data page template where this column should not be displayed).  My new attribute works fine when I hardcode it like this, meaning the HideColumnIn attribute is properly populated with the array of enum values:

<HideColumnIn(PageTemplate.List, PageTemplate.Edit)> _
Public Property My_DD_Column As Object


However, I want to store the values to be used for the HideColumnIn in the DB as integer values that correspond to the

Bug: Specifying values in the definition of an enum in Web Parts in subsites

Pardon the cumbersome title, but I wanted to make it as descriptive as possible! Anyway, I stumbled upon this bug and spent a good while trying to figure out what was wrong. I'm developing a WebPart for use in MOSS 2007. The WebPart in question is mostly unremarkable, but I was getting the following error when editing the WebPart properties: "Some of the properties for this Web Part cannot be displayed properly. For more information, see your site administrator." I've searched Google, Bing and Yahoo for this error and have found nothing, so hopefully this post will be of use to anyone else who searches for it. Turns out the problem was in the enumerator definition. It looked like this:   public enum KPIPalette { Grey = 1, Green, Blue, Orange }   The colour palettes of the components we're using started at 1, so I set the enumerator to do that also. SharePoint, however, had other ideas. The solution is to leave enumerator definitions out. When the number was required later in code, a 1 was added. Error begone, problem solved!

How to cast integer values to an array of enum values?

Hello all! I'm new to VB.NET (and OOP in general) and am struggling a bit...  I'm working with VS2010 Beta2, ASP.NET and Dynamic Data, however I'm thinking this question may be more related to VB so hopefully I've chosen the correct forum. I have a list of integer values stored in the DB and would like to cast them to an array of enum values so that they may be passed to my constructor.  The values in the DB directly correspond to the enum values.  Here is stripped down version of the code that hopefully highlights what I'm attempting to do:Private _pageTemplate() As PageTemplate Public Sub New(ByVal ParamArray pageTemplateArray As PageTemplate()) _pageTemplate = pageTemplateArray End Sub Public Enum PageTemplate Details = 1 Edit = 2 Insert = 3 List = 4 ListDetails = 5 End Enum What I'm having difficulty with is reading integer values from the DB and casting them to an array of PageTemplate() to be passed to the constructor above.  The integer values in the DB will be 1 through 5 to correspond to the enum values listed above.  Here is how I'm trying to build the ParamArray to be passed to the attribute constructor:Dim hideFieldsIn(-1) As PageTemplate Dim rowCount As Integer = -1 If reader.HasRows Then While reader.Read() rowCount += 1 ReDim hideFieldsIn(rowCount)

WPF TreeView child nodes - collection is not a member of the first level nodes object



I was wondering if i could use a TreeView to display data from 2 separate collections where both collections are members of the same object. For example i have a view model that has 2 observable collections:



Each model has a property Brand which specifies the brand for each model. What i want to do is bind the first level to the Brands collection and the second level to the Models collection and specify a filter.

Thanks in advance.

Reference to a non-shared member requires an object reference in code generated by ASP.NET



I am working on converting a project from C# to VB and am facing this weird issue. 1 page cannot compile and I get the reference error, but the weird thing is that the compiler shows the error as coming from ASP.NET generated code. Visual Studio shows me that error is coming from my ASPX page. I cannot seem to figure out why or where this error is occuring. Also if I take the inherits attribute out I don't get the compilation error. The code in aspx page is below:

<%@ Page Language="VB" AutoEventWireup="true" CodeBehind="diff.view.aspx.vb"  Inherits="MR.ControlApp.diffview" MasterPageFile="~/Site1.Master"%>

<asp:Content ID="Header1" ContentPlaceHolderID="head" runat="server">

    Page: <select onchange="sel(this);">
        Dim j As Integer = 0
        While j < pageCount
           <option <%= IIf(currentPage = ( j + 1 ), "selected", "")  %> value="<%= j+1 %>"><%= j + 1 %></option>
        <%j = j + 1
        End While
    <% 'Print(); %>
    <div style="font-family: verdana; font-size: 10pt; font-weight: bold">
        MDM Data Inconsiste

Reference to a non-shared member requires an object reference


This is detaining me from transferring my website to another webserver.  So much for a seamless transfer. I had no problem ever with the following line on several pages on my site:

  <%Dim cust As New BusinessLogic.SiteUser(CInt(BusinessLogic.SiteUser.CurrUserID))%>

This line is used on 4 other pages just like above. The vs 2008 is whining with this error message.

I opend my 2005 vb.net site into VS 2008 and it asked me if I wanted to upgrade for .net 3.5 and I said yes. I cannot debug and I get the mentioned error. Visual Studio 2005 gives NO such error. What is the issue?  How can I resolve this?

What is a non-shared member? I don't think I should have to change anything in my business logic area. Can this line, which does 2 things, be done in the code behind? Or partly in the code behind so as to not give this error?

<%@ Page Language="VB"  AutoEventWireup="false" CodeFile="paypal_featured.aspx.vb" Inherits="paypal_paypal_featured" title="Untitled Page" %>

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <form action="<%=paypalurl%&g

Reference to a non-shared member requires an object reference


I do not receive this error when I open my website application in vs 2005. When I open in vs 2008, I get this error. What gives?

These lines are underlined in blue:

<%Dim cust As New BusinessLogic.SiteUser(CInt(BusinessLogic.SiteUser.CurrUserID))%>

Businesslogic area is imported into each of 3 pages with this line. 

Access Denied for when creating workspace for Contribute Member

Hey guys,

I'm new to sharepoint so please go easy on me. 

Everything on the site works fine with my account. My account is assigned full control for permissions.

I have a member that is given contribute permissions and he can access everything on the site as well (like he should be able to). However, he found a problem tonight in our testing and I've been able to trouble shoot it a bit.

When he tries to create a new workspace, he gets an access denied error. I logged into his account and verified that his account is unable to create the new workspace. My account can create it with no problems. I gave his account full access (instead of contribute) but still he was not able to create a new workspace.


Mukesh Ajmera

Order of Unknown Member amongst Other Member Values


I have a dimension where I have enabled the Unknown Member and set the Null Processing attribute to the Unknown Member.  I've noticed that when I do this the Unknown member is always ordered last amongst its siblings when viewing the dimension within the cube.  I'm wondering if there is a property I can set or if there is some other way of changing it so that the Unknown Member is ordered first among it's sbilings.



Intermittent Access Denied to Users with Member Permission Levels


Hello Community,


I have another tough SharePoint mystery I am trying to solve.  Essentially, users with Member permission levels are experiencing issues accessing a sub-site of a Site Collection intermittently. Users will Full Control, Site or Farm Collection Administrator access do not experience this issue. When the Site Owner with Full Control permission levels opens the site in the morning then the users with Member permission levels are able to access and navigate the sub-site without issue.  Does anyone have any thoughts on what this type of problem may be related to?





Tom Molskow SharePoint Architect - If I solved the issue please propose my reply as the answer - Thanks!

Can't access static member in code, but while running "QuickWatch" sees it. What the?


HI everyone,

I'm working with two Visual Studio 2005 solutions.

The first is "WinX" with a project called "WinX". There's a class in the WinX project in a namespace called "WinX" with a class "frmMain". frmMain is the main form for the application, and is always open.

We have this static member declared as so in frmMain:

public static bool IsfrmViewTaskFormOpen = false;

Enter our second solution "TasksProcessScreen" with a project "TasksProcessScreen" which has a namespace of "TasksProcessScreen" with a public class frmViewTask. The solution has the "WinX" project added as a project.

In frmViewTask, there is the following code:

private void frmViewTask_FormClosed(object sender, FormClosedEventArgs e)


   //This does NOT compile! It says "WinX" does not exists in the current context.

   if (WinX.frmMain.IsfrmViewTaskFormOpen)

Reference to a non-shared member requires an object reference.


I cannot seem to find the answer to this error.  I have read all the posts I could find but nada seem to work.


Here's what I have


Sub Page_Load

Dim clsTest As New clsTest

     Dim myTest As String = clsTest.Test1()    <-- Error Reference to non-shared member requires an object reference

 End sub


Imports System
Imports Microsoft.VisualBasic
Imports System.DateTime
Imports System.Data
Imports System.Data.SqlTypes
Imports System.Data.SqlClient
Imports System.Data.Linq.DataContext

Imports System.Web
Imports System.Web.UI.Page
Imports System.Web.HttpRequest
Imports System.Collections

Public Class clsTest

   Public Shared Function Test1() As String

      Return "Test1"

   End Function

End Class



Thanks for your help







User has access but is not a member of any group


Help!  I have a user that access to all of the content in my site even though he has been restricted for certain lists and for certain items within the list.  

To troubleshoot the issue, I have removed him from all security groups in the site.  He should have no access to anything in the site or any lists.  He can still see the items.  And when I click on a list item and check his permissions, here's what I see.  What do I need to do now?  Where is he getting all these extra permissions?


p.p1 {margin: 5.0px 0.0px 5.0px 0.0px; font: 14.0px 'Times New Roman'} p.p2 {margin: 5.0px 0.0px 5.0px 0.0px; font: 12.0px 'Times New Roman'; min-height: 15.0px} p.p3 {margin: 5.0px 0.0px 5.0px 0.0px; font: 12.0px 'Times New Roman'} table.t1 {border-collapse: collapse} td.td1 {border-style: solid; border-width: 1.0px 1.0px 1.0px 1.0px; border-color: #cbcbcb #cbcbcb #cbcbcb #cbcbcb; padding: 0.0px 5.0px 0.0px 5.0px}

Permission levels given to Matthew (domain\matt) 




The followi

Get Member from LDAP using C# 2.0


I'm currently writing a process where I need to determine if an User on my LDAP string is an Admin.

How can I accomplish this?  What would be the easy and quickest way?

I've been trying to use the code below..... Any feedback is greately appreciated. Tks



enum and switch need help

void Main()
	string t = "Vendor";
	switch (t)
		case PType.Client :
		case PartyType.Vendor :

public enum PType

When I try to run these code got error:  cannot implicitly convert type PType to string

If I change PType.Client to PType.Client.ToString() got error: A constant value is expected


how to use enum in class


hi there
in my class i have this code

  public enum userTypeID
            Superuser = 1,
            User = 2
        public userTypeID Tipo;

and i am trying to use with

int use= int.Parse(CLS_UserType.userTypeID.Superuser)

it return error because it is not possible cast int to enumeration
how can i do to get a value?

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend