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

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

Check if item exists in array

Posted By:      Posted Date: October 21, 2010    Points: 0   Category :ASP.Net


I have a javascript function, in which i have declared an array variable.

var strUsers = new Array("John","Mac","George"); 

The above declaration is for sample and the number of items vary.

How to check, if the particular loggedin user for example: Mac is available in the arraylist.

Thank you


View Complete Post

More Related Resource Links

Check if item exists in e.item.dataitem


I use a ItemDataBound for a repeater.
But i use 2 kinds of linq querys to bind it.

Some of them has a MerkID, and some doesnt have this item.
So its easy i need to do this:



   //Code for linq query 1



 //Code for linq query 2



So of course the if selection doesnt work, but how can i do that?
I already tryed this:

DataRowView drv = (DataRowView)e.Item.DataItem;
if (drv.Row.Table.Columns.Contains("MerkID"))

But that doenst work because he cant convert it to a datarowview because its a linq class.
So what to do?

Right now i use a try and catch, but there are better solutions i guess...

Is there a way to check if workflow instance already exists for a particular productID in Workflow o

I am using Visual Studio 2008 and .NET 3.5. I am trying to build a WF that is exposed as WCF hosted on IIS. This service is consumed by ASP.NET client. It is a very simple WF- receive info for new product "A"- send email to person 'Xyz' that new prodcut "A" is received- do some business process for product "A"- send out more notifications for product "A"Consider this scenario - - Client hits submit on asp.net page for prodcut "A"- new WF instance is created for product "A"- client can go back to the same page, edit some more info and hit save again. However, this time or for any subsequent "Saves",  I do not want to create a new WF instance for product "A".I can check to see if a WF instance exists for product "A" on the client side before calling the service operation. However, I want to see if there is a way to do this in WF or WorkflowServiceHost, as I don't want to add this logic to client. First acitvity in WF has to be receive activity with CanCreateInstance = true, so not sure how I can do this check in WF itself.Also, I have another stupid question, when using WF exposed as WCF service, do we have to implement all service operations using WF? What if I have some service operations that just involves checking some business logic? Do I implement this in a

LinQ to check if xml node exists in the XML??

Using LinQ or any C# syntax, I just want to know whether "Item" Child exists or not if the parent Node (ChildMenuSelected>>MenuSelected) are true from the below xml format.Xml Format:<MenuDataResult> <Items> <Item> <ItemType>Submenu</ItemType> <ItemTitle>Level22</ItemTitle> <Menu> <MenuSelected>false</MenuSelected> <ChildMenuSelected>false</ChildMenuSelected> </Menu> </Item> <Item> <ItemType>Submenu</ItemType> <ItemTitle>Level21</ItemTitle> <Menu> <MenuSelected>false</MenuSelected> <!--if ChildMenuSelected = true --> <ChildMenuSelected>true</ChildMenuSelected> <Item> <ItemType>Submenu</ItemType> <ItemSubType>0</ItemSubType> <Menu> <!--if MenuSelected = true --> <MenuSelected>true</MenuSelected> <ChildMenuSelected>false</ChildMenuSelected> <!-- whether this below item exists or not --> <Item> <ItemType>Submenu</ItemType> <Menu> <MenuSelected>false</MenuSelected> <ChildMenuSelected

How to check if SPFiled already exists?

hi   I donot know the internal name and cannot use title for retreiving the filed because user can add 2 fields with the same title. Is there anyother option to check if filed already exists?

check user exists in which group

After entering user name, i want check user belonging to which group, group is some thing like role based if group is something group1 , then i want redirect hime to page 1, if groupis 2  then page 2 like that

How check if file exists?

Hello I want to delete file, i can do this but firstly i want to check if it exist. What must i add to  my code for this? DECLARE @del varchar(50) SET @del = REPLACE(' del C:\ADFS\Data_'+CONVERT(char(10),dateadd(year,+1,DATEADD(dd, -1, GETDATE())),103)+'.csv','/','.') EXEC master..xp_cmdshell @del

check if a table exists in SQL 2005

I'm trying to check if a certain table exists in a given database on a SQL 2005 Server. I've tried numerous times without any result.   can anyone point me in the right direction?

No item exists at Url. It may be deleted or renamed by another user problem

Hello  all,   I am using strListUrl = subSite.Url + "/" + strSubstring + "DispForm.aspx?ID=" + listitem["ID"] for redirecting the user the list item. But it says the No item  exists at Url. It may be deleted or renamed by another user problem. After some research I came to know, I can't use ?ID=. from http://support.microsoft.com/kb/972225/en-us. Can anyone tell me, what the article is saying or Anyone has any solution.

Check if custom culture exists

Hello, I created a custom culture using the 'Register' method on the CultureAndRegionInfoBuilder class. But if you execute this method when the culture has already been registered, then an exception will be thrown. So, is it possible to check if the culture is already registered on the machine? Regards, Stefan

check if a url exists

is there a way to check if a url or a website exists?

No Item Exists Error

I have a edit form that has a custom list form (call it list A) and several mutli item forms (call these list 1, list 2, list 3) on it. When I try to edit some of the items I get the following error: No item exists at http://stpi35/ResourceAllocation/Lists/Management Fee Survey/EditForm_11.aspx?ID=12&List=f3d96856-bcda-4ef1-ae4e-a0ed0ddb97bc&Source=http://stpi35/ResourceAllocation/Lists/Management Fee Survey/AllItems.aspx.  It may have been deleted or renamed by another user. None of the lists have a column that I created called ID I have noted that if my main item list (list A) has 4 items and one of the supporting lists (list 1) has only 3 items I can edit items 1, 2, & 3 on list A but item 4 causes the error to be thrown. I am guessing the Id = 4 is being somehow applied to list 1 (one of the embedded multi item forms) and since it only has 3 items it is causing the error. The multi item form for list 1 does not have a query string (I am not filter just wanting everything to show) In searching for a solution I came across this article -> http://support.microsoft.com/kb/972225/EN-US The resolution was --> Change the query string parameter from ID to CustomID. Then change the details page from QueryString(ID) to QueryString(CustomID). I can change the query string parameter on the custom list form to CustomID but where is the details page? (If t

Check Box List Item in ASP and JS onClick item


I have a js function to show/hide content placed in a div. I want it to show/hide when a list item is selected in a check box list, but just can't seem to get it to work. Here is my code:

    <script type="text/javascript">
        function showHide(obj) 
                var element = document.getElementById(obj);
                if (element.style.display != 'none') 
                        element.style.display = 'none';
                        element.style.display = '';    

 <asp:CheckBoxList runat="server" ID="cblProd1" RepeatColumns="1" OnSelectedIndexChanged="cbl1_SelectedIndexChanged" AutoPostBack="True">
                            <asp:ListItem onClick="Javascript:showHide('divText1');">Text</asp:ListItem>
                            <asp:ListItem >Text1</asp:ListItem>
                            <asp:ListItem >Text2</asp:ListItem>
                            <asp:ListItem >Text3</asp:ListItem>
                            <asp:ListItem >Text4&l

Invalid length for a Base-64 char array - how do I check the length?????


Invalid length for a Base-64 char array

I am encrypting and decrypting my querystring. I need a way of checking the querystrings length before I decrypt it. When I mess with the querystring, shorten it for example, my decryption method fails. Can somebody help me with the if statement please to check the length of the urlDecode string??????

public static string Decrypt(string inputText)      {          if (!String.IsNullOrEmpty(inputText))

XMLdocument check if path exists (selectnodes throws "Object reference not set to an instance of an


Normally the code below works, EXCEPT if the xpath doesnt exist, then I get the error "Object reference not set to an instance of an object." on the 2nd line

Dim sessionXML As XmlDocument = Session("XML")
If sessionXML.SelectNodes("//root/data/compare/locations/location") IsNot Nothing Then

How can I check if the xpath exists (without a try catch preferably)?

How to check for file exists on remote server in ssrs 2008?

I have a report that needs to display images that are stored on a remote web server. The problem is that I also need to check if the file exists first otherwise I get those annoying image not found red X's.

I tried entering the code at the bottom in the custom code section of the report which works if I run it on my local machine however it doesn't work in SSRS 2008. After doing a little trial and error I found it seems to be failing on the first line in the function,

Dim request = System.Net.WebRequest.Create(New Uri (fileURL))

Is there some specific permissions or configuration change needed on the SSRS2008 server for this code to work? Or is there a better way to do this?


Public Function CheckRemoteURL(ByVal fileURL As String) As String
Dim request = System.Net.WebRequest.Create(New Uri (fileURL))
request.Method = "HEAD"

Dim returnURL = ""

Dim response = request.GetResponse()
returnURL = fileURL
Catch ex As Exception
returnURL =""
End Try

Return returnURL
End Function

Copy List Item in SPD 2010 Workflow Fails if Check Out/Check In Required


I've seen this issue on 3 different Sharepoint 2010 implementations, including upgrades and fresh installations...

The workflow, which works fine in WSS 3.0/MOSS, operates on change of a document.  Workflow reviews a specific column and based on contents of that column, it checks out the document, copies the current item from the current library to another library in the same site and then deletes the item in the current library.

In SharePoint 2010, the following occurs.  Again, this occurs in the upgraded workflow as well as in a brand new workflow created with SPD 2010 on a site that blank / not upgraded.

  • Workflow starts on an item that is verified to not already be checked out.
  • Document is checked out
  • Document IS copied to the other library
  • Workflow fails and is canceled with the following errors:
    The workflow could not copy the item. Make sure the source and destination lists have the same columns and column settings.  (They do.)
    The workflow operation failed because the action requires the document to be checked out. (The item is checked out by workflow - as is evidenced by the fact that the item is still checked out after workflow fails.)
  • RESULT:  the copy operation does work, workflow thinks it doesn't and fails on that step, item is not deleted

I've tes

C# How to check prammatically if null value exists in database table (using stored procedure)?


How to programattically check if null value exists in database table (using stored procedure)?

I know it's possble in the Query Analyzer (see last SQL query batch statements)?

But how can I pass null value as parameter to the database stored procedure programattically using C#?

Although I can check for empty column (the following code passes string.Empty as parameter but how to pass null value?), I cannot check for null value in the following code snippet:

SQL Queries:

USE [master]

IF EXISTS (SELECT name FROM sys.databases WHERE name = 'ExampleDatabase')
DROP DATABASE [ExampleDatabase];

CREATE DATABASE [ExampleDatabase];

USE [ExampleDatabase];

DROP TABLE dbo.ExampleTable;

IsActive BIT,

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