.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

sorting a list by properties of its objects

Posted By:      Posted Date: September 08, 2010    Points: 0   Category :ASP.Net
I have a list that contains several instances of a custom class and I want to sort it by properties of the custom class it containseg  heres the classpublic class Theclass { public long ID { get; set; } public DateTime Date { get; set; } public int Sequence { get; set; } }List<TheClass> lst = new List<TheClass>();lst.add(instance1 of 'TheClass')lst.add(instance2 of 'TheClass')etc, etcso I could end up with a lst object containing many instances of 'TheClass'how could I subseqently sort this list by sequence within IDor by Date within ID

View Complete Post

More Related Resource Links

List of Objects in Declarative Service

I am trying to create a WCF workflow service that accepts requests from a user to add a new user.  I want to add this "user to be approved" to a list of users List<PendingUsers> and wait until an approver approves one. Then the workflow will remove the approved user from the list and add it to the database. Requirements: 1. Pending users should not be added to the database, they should be maintained in a variable until approved. 2. The second ReceiveAndSendReply will return the list of all pending users.   I have created a service with a flowchart that has a flowchart variable that is the list of pending users. The problem is after each call it is lost. I am assuming the workflow is unloading. Is there another approach I can take or some way to keep the List of Users from unloading between calls.

User information list properties SP Foundation 2010

When trying to view properties of user information list in SPD 2010, I get the following error "SharePoint designer cannot display the content of this view (...)" I am logged in as administrator for both farm and site. I can view content of the list in a browser, but I cannot access the list as a lookup column. It works with WSS 3/SPD 2007 on another server.

User information list properties SP Foundation 2010

When trying to view properties of user information list in SPD 2010, I get the following error "SharePoint designer cannot display the content of this view (...)" I am logged in as administrator for both farm and site. I can view content of the list in a browser, but I cannot access the list as a lookup column. It works with WSS 3/SPD 2007 on another server.

Problem binding business objects to custom user control properties

I have created a user control (supplierPicker) intended to allows a supplier database to be searched and a supplier selected. I want to be able to use this control in a number of other user controls, by binding the suppplierID property of the supplierPicker to a supplierID property in a business object, which is set as the datacontext of the parent user control. When I do this, and there is a supplierID specified in the business ofbject, the binding sets the supplierID in the supplierPicker control and it shows the correct supplier name in the textbox. However when the supplierID DependencyProperty is changed from within the supplierPicker the newly selected supplier name is shown in the TextBox, but the SupplierID does not propogate back to the business object. Other controls on the parent form work fine, so the binding to the business object seems to be ok. Any pointers as to what I'm doing wrong here would be grately appreciated.  This one has been driving me nuts for days! Snipped code for the supplier picker:         public partial class SupplierPicker : UserControl, INotifyPropertyChanged     {         public static DependencyProperty SupplierIDProperty;         public event PropertyChangedEventHandler PropertyChan

Keeping Custom properties in GridView Added on OnRowDataBound Event While Sorting

All of my columns are bound in the Gridview. On OnRowDataBound event, I am adding some custom styles like underlines and colors to the text of the columns. Sorting of data is working fine but I am losing my custom styles when I sort. I am using the generic sorting code for the GridView. How I can keep my custom styles on sorting that I added during OnRowDataBound event.   Thanks for your help.

Custom Control - Read Only Properties List

How would I add a (dropdown)  list of available values for a custom server control property?(Just like 'Visible' property of most controls has valid values of 'True/False' and nothing else can be entered or selected)

Sorting the list of attributes (not members) of a dimension


Hi there,

Any solution with SSAS 2008 R2 for that problem?


"It looks very simple, but I cannot find how to order the list of attributes in a dimension. Let's say I have a dimension Item with two attributes:

- Code
- Description

and I want the Description to appear first. By default it's using the alphabetical ordering but can I change that ?"

It works fine with measures. In BIDS, CubeDesigner, there is are up und down buttons in order to move measures up or down. In the attribute pane, these buttons are inactive.

any help?


Set the sorting properties of gridview true but still columns are not becoming links



I have to do a sorting on headers of the gridview.

i have set the sorting property to true and also implemented the onsorting event.

But my headers are not coming up as links,what could be the reason?

Advanced Sorting on a List



I just created a list and my requirement is to sort by last name. However, when I go to the Sort & Group section in SPD, I can't see any advanced sorting options and can only sort by the fields themselves. How would I apply a sort expression to a standard list?


Update all Properties in the User Information List after restoring a site collection to a new domain


hi All

I moved a site collection (content db) from one domain to another. After the site collection was restored i ran the stsadm -o migrateuser -oldlogin -newlogin. The result was that the login id of the user in the source domain was replaced with the login in the destination domain.

However the rest of the properties in the User Information List (paricularly interested in the Email) was not updated.

How can i get all the properties in the User Information List with values in the new domain

Thanks in Advance


List Properties Supporting Files Display item form won't stay set


In Sharepoint designer I am trying to set a custom display form for a list, following the instructions in the Sharepoint designer help.


I've got a functional display form, called DispForm3.aspx. I know it works since I tested it by replacing the form name in the normal URL where a display form is opened.


However I can not get the list to accept this new form as the display item form.


In Sharepoint Designer, in the List Properties Supporting Files tab I set the Display item form to be DispForm3.aspx and press OK. When I look again I see that the Display item for is DispForm.aspx.


This happens on any list that I try to customise the display form for, even new ones.


Sharepoint designer is allowing me to set the display item form to DispForm3.aspx but is not saving it, or is failing silently when it tries to save it.


Any assistance appreciated.


How to create a Class with List<> as properties



I need some help for the above.


I need to read filenames into a List  inside a class.


Example :

1) How to read or get the value into the PhotoNameCollection Class in foreach statement below?


2) How to create a class with List<> as properties and How to do the get and set statement ? Is the below class okk?


 foreach (var pic in PicNames)

     //-- get the filename and add it into the class with List<>


  public class PhotoNameCollection  //<--- Can be Static Class
        private List<string> g_Photoname

        public List<string> PhotoName



Restore List of custom objects on postback


I have a model containing a List with custom objects, let's say Customer objects. Like this:

public class MyModel
public List<Customer> { get; set;}

public class Customer
public int id { get; set;}
public string name { get; set;}

In the View I print out (for simplicity) the name and id of the customer objects on the model. How to restore these values on postback if the method signature looks like this:

public Index(MyModel model)
...here model.Customer[x].Id and model.Customer[x].Name is null...

Should I use hidden values? This is not possible if the List contains items of interface type, for example List<ICustomer> where ICustomer is an interface. Is there any other way to "save" the values on each postback? For example I may want to view validation error messages when the user submits the form and then the properties of the customer object must still be there..

creating dataset using list of objects in Linq



 I am using Linq To Sql to get List of objects with data from database. To bind data with a grid view i am creating a dataset explicitly and then adding List values to that explicitly created dataset.

Now my question is whether it is a good pratice to do what i am doing (in terms of resource utilization) or is there any better way to this...

Metadata properties set in list item, but don't show up in the DIP.


Hi folks,

I'm creating a document programmatically on the server side and using SPFileCollection.Add(...) to create it using the binary contents and a hashtable of the metadata properties.

This works great in SharePoint.  The SharePoint list item picks up the metadata properties and a new document item is created in the library with the proper metadata for all of the fields.  If I view the properties or go to edit the properties in SharePoint, all of the metadata is correct.

However, when I open the document in Word, it seems that none of the managed metadata fields (taxonomy field types) "stick".  The values are only for the managed metadata fields.

In SharePoint, if I change any of the fields and do a save on the list item and then open the document, the taxonomy fields "stick" when I open the document again.

I've opened up the document to view the XML and it seems that the custom properties XML doesn't change from pre-update to post-update.

I've also tried calling SPListItem.SystemUpdate(...) and SPFile.Update(), but this has yielded no results so far. 

So in summary:

  • All fields except for managed metadata fields "stick"
  • All fields show up fine in SharePoint in view and edit mode
  • Managed metadata fields are blank when Word document is open

Question about filter list of objects by interface



public interface ISearchable
      int Id{ get; set;}
      int LanguageId{ get; set;}


class Programmer : ISearchable

    public int Id
            return Id;
            Id = value;

    public int LanguageId
            return LanguageId;
             LanguageId = value;
} public class Teacher : ISearchable { public int Id { get

Searching a list of objects using 'and' and 'or'


I would like to allow the user to be able to perform searches on a large list of objects.  They will be able to search for keywords and use 'and' and 'or' operators.  I am having trouble finding the best way to implement those operators in my LINQ query.  Any suggestions would be appreciated.

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