.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

Split List into sub lists of List of size n

Posted By:      Posted Date: August 28, 2010    Points: 0   Category :.NET Framework
Hi all,   I've been playing around for a little bit trying to find the best way of taking a List<double> of variable size and splitting it in to sub-lists of  size n. So maybe a method stub like   public List<List<double>> splitData(int width,List<double> data) { <br/> }<br/> The problem is i cant get my head around how to iterate through the parameter "data" properly when the data.count is not exactly divisible by the parameter "width". I have been trying for loops but i think i need to switch to do whiles.   I'm not massively familiar with LINQ but could anyone advise if LINQ would provide an alternative way of doing it?   Any help much appreciated   John

View Complete Post

More Related Resource Links

How can I split one Sharepoint 2010 List into two Sharepoint 2010 Lists which are displayed side-by-


I have a list (table) with 50 items which is in a webpart zone of a Sharepoint 2010 page. Unfortunately, users have to scroll down the page to see the last items in the list. Therefore I would like to break the list in two and display both lists (each with 25 items) side by side in the same webpart zone. How can I do this? 

The only thing I can think of is to add a new webpart zone next to the other one, put a copy of my 50 items list in it, and apply filters to the lists so that the left one displays items 1-25 and the right one displays items 26-50. Unfortunately, I will have to change my filters once in a while.

SQL file will not open in SSMS on double-click (or jump list)


Hello, all.

I am running SQL Server Management Studio 2008 on a Windows 7 Enterprise machine here at work.  I am not sure when this started happening, but now, for some reason, when I double-click on a SQL file in Explorer, or from the jump list for SSMS (which I have pinned to my Windows 7 task bar), SSMS will open, but will not load the file in question, nor will it bring up a logon screen to connect to a DB.  I tried unassociating the .SQL extension and then re-associating it using "Open With" and it worked the first time (from the Open With), but then immediately reverted back to its old behavior.  Very annoying.

For now I just open SSMS first (which pops up a logon screen and things proceed normally), but that kind of defeats the purpose of having a jump list or a file association.  Has anybody run into this before and can anybody suggest a fix or what's wrong?

Thanks in advance for any wisdom anyone can provide. 

How to add double integer array to ArrayList. Then iterate through the list and delete an item?


   I have a class with three students in it. Each student has two test scoress for the semester.
   How do I iterate through my ArrayList?

   Also suppose I want to remove a student score from the ArrayList while iterating through the list, How can I do this ?

   An example is if I allow Hallie to drop her lowest score of 71

            int Students=3;
            int Scores = 2;
            int[,] Student = new int[Students, Scores];

            ArrayList Class = new ArrayList();
            // Add joes scores
            Student[0, 0] = 88;
            Class.Add(Student[0, 0]);
            Student[0, 1] = 99;
            Class.Add(Student[0, 1]);

            // Add Maries Scores

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).

Video: SharePoint 2010 Lists, List Data, and CAML

This demonstration illustrates how to work with list data and the Collaborative Application Markup Language (CAML). (Length: 5:05)

Cross list query for two sharepoint lists and a join between the fields

Hello All, I have a requirement where i need to query the data from two  sharepoint lists  on a same site by doing a join between those lists and get the result into datatable.I am doing this using sharepoint object model.Is there any possibility to do this. Any pointers in the right direction are greatly appreciated. Thank you Smith   smith

Cannot delete rows in a list via Lists web service's UpdateListItems-function, even though I am abl

Hi all, I'm trying to delete some rows in a SharePoint 2010 Foundation list via Lists.asmx -web service's UpdateListItems. The web service is called from BizTalk. I am able to create rows, but for some reason delete fails. I also use "GetListItems"-function without problems. The exception I get is Microsoft.SharePoint.SoapServer.SoapServerException. The message is "Cannot access a closed Stream." The updates-element of the UpdateListItems-function is as follows (well, a part of it, the real one has more Method-elements, but you get the gist..): <Batch OnError="Continue" ListVersion="1"> <Method ID="1" Cmd="Delete"> <Field name="ID">1900</Field> <Field name="IMEI">GFA-687</Field> </Method> <Method ID="2" Cmd="Delete"> <Field name="ID">1901</Field> <Field name="IMEI">OVG-567</Field> </Method> <Method ID="3" Cmd="Delete"> <Field name="ID">1902</Field> <Field name="IMEI">OXI-570</Field> </Method> </Batch> I've also tried that Batch without the IMEI-information, as well as with a valid ViewName. Why cannot I delete when I can clearly modify/create rows - what's up with th

Creating Lists On Share-point 2010 Server from .stp list template files using Features

Plz, let me know, how to create list on share-point 2010 server from .stp list template files using features in C#

Versioning lists in Sharepoint (not list items)

I need to keep a track of what all changes have been made to a custom list since it was first created. I need to have track of what columns were added/removed and when. I know that we have versioning for list items so as to keep track of what all changes have been made to an item but what I am looking for is versioning of the list itself rather than the list items. Is this possible?

List Event Receivers firing for all custom lists

Hello, I have a site with two custom lists, and I have created an EventReceiver class to handle the ItemAdded event for custom lists. I have modified the EventReceiver's Elements.xml file to only handle items added to one of the custom lists instead of all custom lists, by changing: <Receivers ListTemplateId="100"> to <Receivers ListUrl="/Lists/MyCustomList">   however, when debugging, the ItemAdded method is being fired when an item is added in both custom lists. I have had to work around this by checking within the ItemAdded method for the list that fired the event:        public override void ItemAdded(SPItemEventProperties properties)        {            base.ItemAdded(properties);            if (properties.ListTitle.Equals("My Custom List")) { ... } I thought the ListUrl attribute of the Receivers element specifies the event to only fire for the specific list with that url? (see http://msdn.microsoft.com/en-us/library/ms431081.aspx). Is there somewhere else I should be checking?   Thanks

less than the size of the argument list.

Hai friends, I am updating data to Database(SQL SERVER) The following  Error occurred in RunTime,                       Index (zero based) must be greater than or equal to zero and less than the size of the argument list.Please give some guide.

Starting a list of lists with values

Dear wizards, In C# we can start a List with values as follows: List<double> foo = new List<double> (new double[10]); This will yield me a list with 10 0's. However, I wished to do something like this: List<List<double>> = new List<List<double>(new double[10])>(10); In other words, I would like to start up 10 Lists, each having 10 zeroes.   Grateful if someone help me out  

Add managed metadata column to list - access denied + terms not visible in lists


Firstly the following is not a problem for users given "Full Control" (and possibly other permission levels might work) at the web application level in central admin.

For any other user with permissions set at site collection level, even "site owners" (full control) , these problems arise.

  1. When adding managed metadata columns to a new document library list, clicking save results in multiple access denied errors getting logged (as seen using UlsViewer) and an exception is raised (sharepoint error page)
  2. In existing document library lists managed metadata column headings are displayed in list views but the terms text is not displayed.
This problem shows up even if the logged on user is the term set owner.  "Available for tagging" is enabled, submissions policy is closed.
Looking at http://<the-site-domain>/Lists/TaxonomyHiddenList/AllItems.aspx and then checking list permissions I can see that "All Authenticated Users" has Read permission level.
Integrated windows authentication - NTLM + Claims Based Authentication is the only authentication method used. It's an intranet site. 

Thanks in advance for any help.

what are the List Types for lists in the IT Team Workspace template



What is the list type for the lists in the IT Team workspace?  I wanted to use a CQWP to retreive data but neither "Custom", "Tasks", "Project Tasks" nor "Issue Tracking" worked.

I created my own "Custom", "Tasks", "Project Tasks" and "Issue Tracking" within my IT Team Workspace and the CQWP drew that data (as I had it set to draw the type from the entire site).  So clearly there are no Customs, Tasks, Project Tasks and Issue Tracking types in the IT Team Workspace template.

Thanks for your advice.


PS reposted per advice from forum SharePoint 2010 - Using Visual Studio with SharePoint and other programming http://social.technet.microsoft.com/Forums/en-CA/sharepoint2010programming/thread/55951ded-2d90-4830-a692-d8e1d0b08f00

Designing lists: Quick key combination for adding a new list column field?


I'm simply looking for a way to quickly design lists, and I find it rather slow to use the mouse to go to the Add New Column button in the ribbon every time when I want to add a new list field.

The only column that can't be changed type of later seems to be the Calculated column. But for all others, you can still change them afterwards.

Index (zero based) must be greater than or equal to zero and less than the size of the argument list

Hi, I have installed German and French language packs on my SharePoint 2010 server. After I change the Language settings to be able to select both the languahges as alternate language, I get this error:

Index (zero based) must be greater than or equal to zero and less than the size of the argument list.

It is now not letting me change back the properties back to English only or opening the home page of the site.

Any idea, why this is happening and how can I disable this language pack option from this site collection only so that it works normally as before applying language packs? Do I have to unisnatll language pack for that?

Please guide.


Removing "External List" option from Custom Lists?


We are in the process of upgrading from SharePoint 2007 to SharePoint 2010.  Our business users have noticed a new option of creating a new "External List" under the Custom Lists heading.  Is there any way to remove the External List option without having to customize the create.aspx page?

Andy Kreider | Principal Financial Group | Des Moines, IA, USA
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