Arraylist to Hashtable

Posted on 2006-06-01
Last Modified: 2008-01-09

I have an arraylist which is built based on a recordset.

                    public ArrayList userRoles=new ArrayList() ;
                    string sqlroles;
                    sqlroles = "Select zrole_id from z360core_user_role where zuser_id="+ UserId ;
                    userRoles = Db.RecordSet(sqlroles);

                    foreach (Hashtable Rl in userRoles)


The output is exactly what I wanted. This means that the data is available in the arraylist and hashtable.

I have someother function, I have a value from the db


I need to check if this value is available in the userRoles arraylist.

If I try to use
if ((userRoles.IndexOf(Convert.ToInt32(Db.ColumnValue("zrole_id")))==-1))
            return false;  
its failing

How should I check if  Convert.ToInt32(Db.ColumnValue("zrole_id")) is there in the userRoles arraylist??

Pls help
Question by:sureshraina
    1 Comment
    LVL 2

    Accepted Solution

    As per your sql select statement, the 'zrole_id' column is in number format (and almost an Int32 format). Therefore your ArrayList will be as the same format for thier objects.
    Now I did not understand what is the ColumnValue will retrieve. But anyway, if you want to check if a specified value exist in the userRoles ArrayList, you could use the code below:

    int x;
    x= 5 // or whatever

        return false;

    BTW, why you don't move towards the using of ADO.NET rather thatn the traditional ADO if you are using ASP.NET (aspx) application. It is more relaible, no need to add an ActiveX control, and many other features.

    Good luck

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Is Threat Intelligence?

    Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

    One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on could not pull conte…
    Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
    how to add IIS SMTP to handle application/Scanner relays into office 365.
    Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    11 Experts available now in Live!

    Get 1:1 Help Now