.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

Using array with unkown number of items

Posted By:      Posted Date: April 10, 2011    Points: 0   Category :Windows Application

Hi Everyone,

I'm trying switch from using arraylist to arrays. Seams like arrays are not as easy to use when you don't know the size of the array.

Is it possible to use an array without having to specify the size of the array like in this example?

Thanks in advance.


 dr = cmd.ExecuteReader

                    Dim counter As Integer = 0
                    Dim myarray() As String
                    While dr.Read()
                        myarray(counter) = dr("FirstName").ToString
                        counter += 1
                    End While

                    Return myarray

View Complete Post

More Related Resource Links

Cannot count number of checked items using jQuery

Hello,Using Microsoft built-in jquery files, when counting numbers of checked checkbox, the jquery-1.4.2.min.js cannot count the correct result ,however, the version jquery-1.3.2.min.js gives out the correct one, why?            $("#check").click(function () {                var nameSports = new Array();                var i = 0;                $('input[name=selector]:checked').each(function () {                    nameSports[i] = jQuery(this).val();                    i += 1;                });                if (loopCounter != 0) {                    alert(i);                }  

showing number of items in sub folder

Hi, In "All Site Content", we can see the number of items under each folder. But when we open the folder for example Documents, if it has sub folders, there it does not list the number of items. How to list the number of items in the sub folders. Thank you

How to apply color to selected number of items in check box list and drop downlist

Hi all,    I want to apply color to selected number of items in checkbox list and seleted number of items in drop downlist for e.g color red for few items and black (default). I have a bit value set in data base so if bit is set to 0 then red and if 1 then back. Please help me.  

Maximum number of items in a SharePoint 2010 list

Hi, Is there a recommended maximum number of items that can go into a SharePoint 2010 list? I seem to recall that earlier versions seemed to have performance problems with more than 2000 items. I have a table that has some 50,000 records and would love to convert it into a list.   Thanks John JohnSpilker

View All Site Content Showing the wrong number of items

NOTE:  Similar post also had no answer: http://social.msdn.microsoft.com/Forums/en-US/sharepointecm/thread/f775ba0d-648f-4be3-9017-78539915b281/ I am the Site Collection Administrator/and also tried logging in using Farm Account.  I go into View All Site Content and I show 15 documents.  When you actually go to the All Items view (and I double-checked, no filtering), you only find 9 documents.  Versioning is not turned on.  I am a developer, so I also used the Web Service to try to troubleshoot.  The Lists.asmx web service shows an Item Count of 15 using the GetList method.  However, using the GetListItems method, the item Count reports 9 items, which is what I see in my browser. Is there an stsadm command that I can run that will "true up" this number being reported in View All Site Content? Thanks in advance. - Update -  MOSS 2007 v 3.0 server farm.

Large number of items in SharePoint calendar


We have a department with a calendar that has over 400,000 items.  We're thinking it somehow got that big due to them linking with outlook.  We've turned that off but the items are still in SharePoint in the calendar.  This is causing a great deal of blocking when that calendar is accessed (CAML queries).  They take several minutes to run and block anyone from doing anything in SharePoint (like saving documents or even accessing SharePoint).  We'd like to just delete the 400,00+ items but I'm not sure what all tables are involved.  I've found that the tables docs and UserData each have the 400,000+ records relating to the calendar in question.  I don't want to simply delete the records from these tables only.  Does anyone know what I need to do to clear the calendar?  Is there a way in SharePoint to just delete the whole calendar and it delete the records where needed and then add the calendar back (and it be empty)?



What would make array.length return an incorrect number?


[sub-titled: array.length is working correctly, but Nick has almost certainly done something stupid.] 

This is probably obvious, but has got me mystified.  I have an array which is being created like this:

var TempPoints = $get('<%=PointList.ClientID%>').value;
PointsList = eval(TempPoints);

The field coming in from the server is formatted like this:

[[1,2], [3,4], [5,6], ......... [99, 100]]

So, after the eval has done its work, PointsList is an array of objects, each of which is an array containing two numbers.  If I then do a PointsList.length, I would expect to see the number of elements in the array.  I then of course need to remember that the array is zero based and that the last element is (PointsList.length - 1).  Well, so I would have thought!

In fact, the length seems to be reporting one more than it should, so the last element is actually (PointsList.length - 2).

That is borne out by what I can see in the Visual Studio debugger:

Visual Studio Screenshot

As you can see there, the array has elements 0 through 138 - but the length is reported as 140.

What am I missing?



Display number of items for each metadata in navigation.



Is it possible to display the count of number of documents for specific keyword category in library's metadata navigation? For instance - Draft (1), Approved (0) - or if categories with no documents were not shown at all.


Issue in LookupField control when the number of items exceeds 20


I have one strange issue in using LookUpField control in my publishing page layout. The issue comes when the lookup list grows beyond 20 items, the behaviuor of lookup is changed. If the number of items is more 20 then the control generate a TextBox and an Image and we receive the following error:

Microsoft JScript runtime error: Object required The problem is raised in the Core.js file in the AbsLeft method.

function AbsLeft(obj) {
var x=obj.offsetLeft;
var parent=obj.offsetParent;
while (parent.tagName !="BODY")

 x+=parent.offsetLeft; return x;


I have debug the JS and come to know that BODY tag never comes in while loops so it gives error over there.
If I set fixed Top and Left values then everything works fine.. But I cant as my application will run into different environment with different resolution.

Please help me out on this.

Shahejad Shaikh SharePoint Developer, Gateway TechnoLabs.

how do you get object array number in a method?


Lets say you have four array objects.

test[1] = new test();

test[2] = new test();

test[3] = new test();

test[4] = new test();

then you have your class:

public class test()


   public int i; //initialize some fields

   public int getnumber()


  // what is the array number of the this object? 1, 2, 3, or 4???



so basically, if an object is called: test[1].getnumber   how can this method internally determine what object array number it is currently in?  (without passing an integer from the page)

  it can be either 1, 2,3, or 4.

How to get a list of unkown number of Object from a custom Activity Designer



I'm  trying to get a list of Object of unknown size. I use a stackpanel in my designer to have as many ExpressionTextBox as needed. The number is only known at design time through an ExpressiontTextBox and a validate button. Once the button is clicked, I generate the ExpressionTextBoxes as follow :

    Private Sub btnValidate_Click(ByVal sender As System.Object,
                                  ByVal e As System.Windows.RoutedEventArgs)
      stack.Children.RemoveRange(0, stack.Children.Count)
      For i As Integer = 0 To (

MOSS 2007 This list or library contains a large number of items.


I have a library showing "This list or library contains a large number of items.".

The library contains only 1300 items.


1. Would the performance, e.g., upload files/change item properties, be affected?

2. Any way I can better organize the items?

3. I kown we can create folders in a library, how can I create subfolder? Or subfolder refers to Content Type?

4. Would create content type improves performance?


Many thanks.

perevent limit number of items in contentquery webpart




I want to perevent limit items from content query webpart .

there is a check box in the editor called "Limit the number of items to display". How Can I uncheck this check box by code ?


jQuery: Styling DropDownList Alternating Items (Rows)

In the following example, I will show how you can style any asp:dropdownlist very easily.

The example demonstrates how you can change alternating row items background color, using the fadeTo() to add a nice touch in the dropdownlist. You can change alt rows with a couple lines.

Hide a repeater in ASP.NET C# if the DataSource contains no items?

I have an ASP.NET page that uses a repeater nested within another repeater to generate a listing of data. It's to the effect of the following:
In the (C#) code-behind I'm basically using LINQ to pull a listing of information from an XML document and bind that information to the first repeater.

Searching for the answer to this, it seems the method is to determine whether the data for the nested repeater is empty. If it is, then you set the visibility of the repeater to false.

Creating SharePoint items with CreateItemActivity

Instead of creating new list items from code in your workflow you can use CreateItemActivity. CreateItemActivity can be used for creating list items or files. Properties of interest for this activity are the following (most of them are self-explanatory):

Creating Sites/Lists/List Items under Current User Context in SharePoint By Using SPUserToken

Usually we do this by performing the action under RunWithElevatedPrivileges method and updating the listitem using SPListItem.SystemUpdate() method (see here). but this approach has its own flaws like (RunWithElevatedPrivileges will run under system account, we cannot use SystemUpdate for SPSite,SPWeb,SPList, since it runs under system we will "CreatedBy" by as SystemAccount).
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