.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

ArrayList indexes not set properly

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

I have some basic code to fill items in an ArrayList as follows:

Dim intSteps As ArrayList = New ArrayList()
Select Case Session("type")
Case 1
Case 2
Case Else
End Select

Dim j As Integer
	For j = 0 To intSteps.Count - 1
        Response.Write(intSteps.IndexOf(j) & " : " & intSteps.Item(j) & "<br />")

The issue is that for Case 1 the output is:

0 : 0
1 : 1
2 : 2
-1 : 6
-1 : 11
-1 : 12

For Case 2, it's:

0 : 0
1 : 1
2 : 2
-1 : 5
-1 : 6
3 : 11
4 : 12

And for Else, it's:

0 : 0
1 : 1
2 : 2
3 : 3
4 : 4
5 : 5
6 : 6
7 : 7
8 : 8
9 : 9
10 : 10
11 : 11
12 : 12

Why is the index being set as -1 for a few items?

View Complete Post

More Related Resource Links

How to bind TemplateField DropDownList with ArrayList?


Hi Expert!

  I'm trying gridview templateField DropDownList bind with arraylist. When i set bindsource i got this error. "//Error Object reference not set to an instance of an object."

My Sample .aspx

<asp:TemplateField HeaderText="Type">
                        <asp:DropDownList ID="_grvcboType" runat="server" Width="117px" DataTextField="Display" DataValueField="Value">
                        <asp:Label ID="Label7" runat="ser

connection to SQL Server files (*.mdf) require SQL server express 2005 to function properly.


I dont have the SQL EXPRESS installed instead I have SQL Standard Edition.

 I have two SQL Server instances installed.

 1- UserLT (this is sql 2000)
2- UserLT\SQL2005 (this is SQL 2005 named instance)

But when i try to add a database to my VS website project I get the following error:

Connection to SQL Server files (*.mdf) require SQL server express 2005 to function properly. please verify the installation of the component or download from the URL: go.microsoft.com/fwlink/?linkId=4925

I went in Tools>Opetions>DataBase tools>Data Connection>Sql Server Instance Name (blank for default)

and changed the "SQLEXPRESS" to "USERLT\SQL2005".

But I still get the same error message. Any ideas how i can resolve this issue?

Intermittant error: "A connection attempt failed because the connected party did not properly respon



I'm having a doozy of a problem, and can't find a solution.  I have a WFC Web Service installed to a pair of servers, and accessed through a load balancer.  I am accessing the service from an ASP.NET client app, also via WCF.  The Client is not load balanced.

I'm getting an intermittant error:

(Inner Most Exception) System.Net.Sockets.SocketException:  A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond x.x.x.x:80

(Middle Exception) System.Net.WebException: Unable to connect to the remote server

(Outer Exception) System.ServiceModel.EndpointNotFoundException:  Could not connect to http://<MYSite>/<MYApp>/<MYService>.svc. TCP error code 10060: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond x.x.x.x:80.

I can reproduce this error with about 20% reliability if I execute the exact same page request on the client from 2 browsers at the same time.  When the problem occurs, the successful p

Query an arraylist of array list using linq


I have an array list called Customer. I t holds a list of array list which has the account details.

proj.customer -> collection of arraylist of type customer

proj.customer.account -> collection of arraylist of type account

Account array list holds type account and it has a poperty account balance. How can I query all accounts which has account balance  >100

I tried the following one

var Accountlist= from Account accountdetails in proj.customer.account

where accountid.balance >100

select accountdetails.id

But it is always throwing an error saying cannot cast type customer to type account

Please help

ArrayList.ToArray fails!


In my app, I have code similar to the following:



               ArrayList alStartFrames = new ArrayList();
                byte[] abytTest = { 1, 2 };


                byte[] abytCombinedFrame = (byte[])alStartFrames.ToArray(typeof(byte));

            catch (Exception ex)

The call to ToArray always fails and the exception is caught even though I'm pretty sure alStartFrames is an array list of byte arrays. Anyone have any insight on why this is happening?! TIA

Debugger not loading properly and exiting


I am attempting to debug my Visual Studio 2005 project. I have Internet explorer 8 and it's running on IIS.

When I hit the "debug" button, a new Internet Explorer browser window opens and my ASP VB .NET application loads normally. However, Visual studio returns back to regular editting mode and I can hit the "debug" button again. No break points hit but my web page still runs and loads normally.

The Output screen use to show Web.Server(exit 0) but now it doesn't show anything.

Any help would be greatly appreciated, I've been trying to find a solution for a while...


Discussion board template of SharePoint 2007 not working properly


Use case 1 – Discussion board to suggest change to documents

 User adds a suggestion. The discussion board needs fields like module name, document name, section name and reason for a change etc.


 Problem 1 – When I try to add fields to the discussion board – When a user wants to post a reply to a suggestion, user screen shows the new item form and all fields instead of just a reply or comment field. Need help how can I ensue user only sees reply or comment field?


 Problem 2 – If I make these changes in the discussion board template through SharePoint designer 2007 and later if we plan to upgrade to SP 2010. Do I have to redo the changes I did on old discussion board or will upgrade take care of migration of the changes to new discussion board template available with SP 2010? 




Cannot properly join lists in SPD 2007


Ok, I have been reading all sorts of posts and such for about a week and still have no come up with any concrete answers.


I cannot properly join lists in SP 07. I say properly because I never get the option to select a field to associate one with the other. 

I select "Create new linked data source" from Data Source Library; Pane opens; Left Click "Configure Linked Data Source"; Add 4 to 5 lists from "Current Site"; Select Next; Select Join option but Next is greyed out. Is this supposed to be greyed out because they are lists? Can lists be joined? I see alot of examples on joining databases and excel pages but not too many on lists.

If I select next from the last point, open the linked sources and select my newly created linked source and click to show data, I can see all of the information in there. Problem is I don't believe the lists are really joined by anything since I never received an option for it. 

I also have been reading up on joined subviews but I never receive an option for  joined subview. Is the joined subview the way to go for lists? If so how?


I know these boards are fairly active and any information or help would be greatly appreciated.

Why feature with event receiver doesn't activate properly after site provisioning?



I have defined feature with event receivers for my document library and for users List .

I try to activate my feature in onet.xml in section <WebFeatures>. After provisioning a new site from onet.xml  all work fine and my feature is shown as activated, but event receivers doesn't fire. It fires only after reactivating my feature (deactivate, then activate it again). But I need my feature works immediately after site provisioning without deactivating and activating it again. Who knows how to solve this problem?

part of ONET.xml



        <Feature ID="00BFEA71-4EA5-48D4-A4AD-7EA5C011ABE5"/>

        <!-- TeamCollab Feature -->

        <Feature ID="F41CC668-37E5-4743-B4A8-74D1DB3FD8A4"/>

        <!-- MobilityRedirect -->

        <!--My EventReceivers Feature-->

        <Feature ID ="41178843-A6A4-47c7-9EF9-B8A432E02B88"></Feature>





can anyone tell me why setInterval is not working properly i want to display the time every seconds,

setInterval is suppose to execute the script every second there getting the most uptodate time of day , but it does not update it stays the same
      <script type="text/JavaScript">

          function interval() {
              setInterval("time()", 1000);
          function time() 
              var d = new Date();
              var time = d.getHours();
              var time2 = d.getMinutes();
              var time3 = d.getSeconds();

              document.write(" : ");
              document.write(" : ");
  // -->
      <input type="button" OnClick="interval()" value="Click Me!"/>


XMLSerializer don't handle mixed contents properly

mixed content model allows a combination of text and elements in the XML document. we use .net xmlserializer to serialize/deserialize the XML. XmlSerializer don't handle mixed content properly. XmlSerializer handles mixed content models to a degree. XmlSerializer add the text in the xml document, but the position of text is not exactly where they appeared in the original XML document. Let's take a example here is original xml <employee xmlns="http://example.org/xmlserializer">   here is some text...   <id>333-33-3333</id>   here is some more...   <name>Bob Smith</name>   and here is even more... </employee> We deserialize above xml using the xmlserializer then we serialize it back into xml. Now xml document is changed as follows <employee xmlns="http://example.org/xmlserializer">    <id>333-33-3333</id>   <name>Bob Smith</name>   here is some text...   here is some more...    and here is even more... </employee> You see the position of text is changed. I have seen the Microsoft code to serialize/deserialize the xml through reflector. They put text in a string array but position is not saved. Is there any solution or workaround? I don't want to parse the xml by xmlReader. I want fix in the Microsoft generated classes that ar

How to remove indexes

How to remove indexes..as it is created by mistake I have read that if it will be deleted then data will be deleted also...PLease clear the case of removal of clustered and non clustered indexes..."SQLSERVER DBA" "INDIA"

The application failed to initialize properly (0xc0000006)

Hi, I have been trying to solve the above message when executing an application build with Microsoft Visual C# 2008 and Net Framework 3.5. I execute the application remotely on a cmd archive using \\server\share\app.exe The only acceptable solution I have found is http://social.msdn.microsoft.com/Forums/en-US/netfxbcl/thread/938b9bed-f317-4cca-9ec2-b6e8105f629b/ but it does not work. I executed the following command on the remote folder C:\Windows\Microsoft.NET\Framework\v2.XXXX\ caspol.exe -m -ag LocalIntranet_Zone -url file:\\server\Share\* FullTrust and it says ok, but it does not work neither. One thing to notice is that if running \\server\path\app.exe and change to \\server\path2\app.exe then it works!! Any advise? Many Thanks. Regards, Salva    

Deleting Tables...Properly

Hi, is there someone out there who can help me delete tables properly from sql server? The other day I right clicked and deleted a table from the explorer bar and now I want to name a new table the exact same name as the old one. The problem is for some reason sql sever says that the old table still exists! I'm sort of a bigtime noob in terms of operating the sql environment so...yeah. Thanks!

Creating BaseWindow properly

Just getting going in WPF, I'm sure it's something simple -- don't assume that I'm down the right road.  Using VS 2010, targeting .Net 4 Client. I've created a BaseWindow class which has a property to hold the logged-in Employee, so each window in my app can get to it easily.  This Employee object lives in a "core" dll outside of my WPF application (but I have a reference to it), and the BaseWindow lives right in my WPF app.  BaseWindow inherits from System.Windows.Window. The problem is, when I make a window inherit from BaseWindow (i.e., change the Window tag to "local:BaseWindow" and add a "local" namespace to myself, the designer starts throwing out errors that it can't find the "core" dll.  I don't understand, as the "core" dll is easily available; compilation/testing doesn't have any trouble finding it.  Also, there's no place in the window the designer needs to reference that dll.  The "core" dll is strictly domain-layer objects, nothing to render out of that. By switching my window's tag from "Window" to "local:BaseWindow", rebuilding, and reloading the designer, I'm pretty confident in my discovery.  Every time my Window is just a Window, the designer works great; when it's a BaseWindow, can't load the "core" dll. S

sending email in asp.net A connection attempt failed because the connected party did not properly re

Hi everyone,   I am sending email , but getting this error on this line smtpClient.Send(mail); "A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond IP adress ...   MailMessage mail = new MailMessage(); mail.To.Add( "test@mywebname.com"); mail.From = new MailAddress(txtEmail.Text); mail.Subject = "Testing Email";   string Body = "Demo Email trial"; mail.Body = Body; mail.IsBodyHtml = true;   SmtpClient smtpClient = new SmtpClient(); smtpClient.Host = "mail.mywebname.com"; smtpClient.Credentials = new System.Net.NetworkCredential("test@mywebname.com", "passwd"); smtpClient.Send(mail);   plz help me

Package 'DataWarehouse VSIntegration layer' has failed to load properly

Hi, In my VSTS, I am not able to create a new SSIS project. When VSTS Opens It gives me following error: --------------------------- Microsoft Visual Studio --------------------------- Package Load Failure Package 'DataWarehouse VSIntegration layer' has failed to load properly ( GUID = {4A0C6509-BF90-43DA-ABEE-0ABA3A8527F1} ). Please contact package vendor for assistance. Application restart is recommended, due to possible environment corruption. Would you like to disable loading this package in the future? You may use 'devenv /resetskippkgs' to re-enable package loading. --------------------------- Yes   No   ---------------------------   Also, in Tools the options for Business Intelligence designer is missing.   Please help me!!Sonia Mawandia http://sqldeveloper-sonia.blogspot.com/
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