.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

Ordering in EditorFor

Posted By:      Posted Date: September 10, 2010    Points: 0   Category :ASP.Net
I have a complex view built of several layers of EdiorFor's following my graph of objects. Is it possible to specify the ordering when using EditorFor on an Entity Framework collection i.e.                      <%: Html.EditorFor(m => m.CHURCHes) %>                         <%//: Html.EditorFor(m => (from ch in m.CHURCHes orderby ch.SERVICE_YEAR descending select ch) ) %>instead of<%: Html.EditorFor(m => m.THINGs) %>to do <%: Html.EditorFor(m => (from ch in m.THINGs orderby ch.YEAR descending select ch) ) %>or<%: Html.EditorFor(m => m.THINGs.OrderBy("YEAR") ) %>(without resorting to deep copying my data into POCO objects, sorting those, and then building a view against those ?)

View Complete Post

More Related Resource Links

HTML.RenderPartial vs HTML.EditorFor


This maybe a lame question but I wanted to understand the detailed differences between HTML.RenderPartial and HTML.EditorFor. I am using ASP.NET MVC2 with Framework 4.

Can someone point me to a link?

Validating Custom Types and Html.EditorFor() Templates?

I'm finding my self with the problem that if I do not show the Template for a "complex" object I have in the main view object I still get the errors in the summary. How do i get around this? I've got a model with say:   HouseType ->Persons (has its own editor template) ->Pets(has its own editor template)   In the create view I show each one depending if they are not null. But when I try to validate HouseType and say I have Persons not null and pets is null. I get errors of validation for pets. How do I get around this? -Thanks

Specify width on EditorFor input field

I happily use the new variant of TextAreaFor that allows me to specify the width for the field. TextAreaFor<TModel, TProperty>(HtmlHelper<TModel>, Expression<Func<TModel, TProperty>>, Int32, Int32, Object) Is there any way I can set the width when using an EditorFor or TextBoxFor method? 

How to exclude one of model's property from the Html.EditorFor

Hi, I would like to exclude one of model's property from the Html.EditorFor. I tried  [HiddenInput(DisplayValue=false)]  but it renders the property as an hidden input. This could potentially be a security problem. How can we completely exclude a field from Html.EditorFor? Thank you,Max

how to do Ordering as alphabets first and Numeric ?

Hello All, ORDER BY orders the value as 1) Special characters 2) Numeric 3) Characters I want to ORDER BY the values as 1) Characters 2) Numeric 3) Special Characters for Eg. 1Yamaha, Suzuki, **Ducati, Harley Davidson, 2Honda should be in the order Harley Davidson Suzuki 1Yamaha 2Honda **Ducati  Thanks.

MVC 3 - EditorFor - Not rendering additional viewData

Hay Have seen in the MusicStore PDF witch can be sownloaded from wwww.asp.net,That is it possible to render additional vew data.so:I have my ViewDataModelpublic class PageViewData : Cms.Web.Areas.Management.Model.ViewData.BaseViewData { public ICollection<Page> PageList { get; set; } public Page CurrentPage { get; set; } public ICollection<PageTemplate> PageTemplateList { get; set; } public ICollection<Language> LanguageList { get; set; } public PageViewData(IPrincipal user, MessageCollection messageCollection) : base(user, messageCollection) {} }I have the Model: public class Page : BasePage { public virtual string Keyword { get; set; } [Required] public virtual Language Language { get; set; } public virtual PageTemplate Template { get; set; } public virtual bool IsFrontPage { get; set; } public Page() { } } In my controller, I add the data into the model: public ActionResult New() { this.CmsViewData.CurrentPage = new Page(); this.CmsViewData.PageTemplateList = this.PageTemplateService.GetList(); this.CmsViewData.LanguageList = this.LanguageService.GetList(); return View("New", this.CmsViewData); } And I try to render it with H

Re-ordering the Columns in a ListView



I have a listview bound to a Collection 
The Grouping propertyName is speified as below. 

<CollectionViewSource x:Key="view" Source="{Binding FieldParams}">


                    <PropertyGroupDescription PropertyName="PlanValue"/> 



Also specified is a Group Style 

    <ControlTemplate TargetType="{x:Type GroupItem}" >


                                            <StackPanel Orientation="Horizontal" Background="PowderBlue" >

                                                <Border BorderBrush="Yellow"

Help with design choice -- selecting parts for ordering table


The next part of what I'm working on will involve adding parts to an order, and will be more complex than probably anything I have done.

The amount of parts to choose from will be very extensive.

Anyone care to plant the seed,  have an example, or helpful input on easy ways to select the parts,  add them to a temp table/data table/data set, until all parts are selected (?), and insert into the database when done?

Dropdowns would, in cases, have a large amount of items. Select items from a gridview Master/Detail style? Checkbox lists?

I'm not looking for code, just a point in the right direction. I've looked at some shopping cart/e-commerce type designs, but it just doesn't fit what I'm trying to do very well.



Struct field ordering


I am puzzled

Look at this arbitrary struct:

public unsafe struct Inner
        public fixed int F1[17];
        public byte pad;
        public byte pad2;
        public byte pad3;
        public fixed double F2[17]; // a double is the biggest type supported for 'fixed' buffers.
        public double F3;
        public byte pad4;
        public decimal F4;
        public byte pad5;
        public DateTime F5;

You will see that F3 has the same address as the struct itself does, and is thus actually the first field in the memory block NOT the 6th as one would expect, very surprising indeed because the struct (by default) has a LayoutKind.Sequential.

Now the MS docs say


Indicates that the members of the type are to be laid out in unmanaged memory in the same order in which they appear in the managed type definition.

Now this could mean t

Custom Ordering in Document Library


Hi All,

I would like to order the document library folders and files (in those folders) on a custom column. Is that possible? For example, I would like to create a "number" column and sort the items based on that column.

Are there any other alternatives?


Column Ordering again


There is a post: http://forums.asp.net/p/1427082/3185309.aspx#3185309?Re%3a+Column+Ordering

that has a snippet 

[Display(Name = "ID", Order = -1)]


from the asp.net team and mentions it is in release 4.  The post is from april of 09.  It is Oct of 2010 and my current version of DD does not have a Display attribute, only DisplayName.  Did I miss something?  Did it not make it in?  I found a codeplex (?) article on ordering columns, but I don't want to modify the defaults this far into a project.  Thoughts?

Column ordering not working


Anyone have any idea why my column ordering would not be working?

It doesn't work in any of my site collections, on any library or list. 

Thanks in advance.

Address Ordering



I have an address column however the ordering does not work when the address number goes above 10. i.e. address are ordered like so

1 address street

10 address street

2 address street

I am not guaranteed to know the length of the number of the street, nor if there will be one. To also complicate things the address could also be Flat 1, or Flat A, 1 Address Street.

I have been messing around with Patindex but it does not appear to be in SQL CE.

Anyone with any ideas?

ordering self referencing employee dim by employee name


Hi.  I just noticed that when I expand my self referencing employee dimension rows and employee name was chosen as the attribute, the sort order appears to be the PK of the employee star table.  I played with the OrderBy and KeyColumns in the properties of the name attribute to no avail.  At the moment the Key in this attribute's properties is the employee name itself and the OrderBy is Key.

How can we order expanded attribute rows by name when name is chosen?

We run STD 2008.  I cant afford to renumber pks every time an employee is added.  At the moment there is no user defined ssas hierarchy in this dim's designer panel.  My recollection is that a hierarchy here might interfere with the security and/or self referencing behavior but I may be mistaken about that and would have to reread some old notes if that becomes an issue. 

Pondering ASCII ordering in a string comparison



The following query on SQL Server:

Select case when '9:9' < '99' then 1 else 0 end
returns 1

Given, according to http://asciitable.com/ ':' comes after '9' I am surprised that the above query does what it does. Then again I'm clearly making a wrong assumption somewhere.

Can anyone explain this?




http://sqlblog.com/blogs/jamie_thomson/ | @jamiet | About me
Jamie Thomson

Ordering sold quantity



I have written the below code it shows this data  

SKU Title QTY Cost
a b 10 20
c d 30 10
e f 5 100

As you can see the QTY isn't sorted like e should be above a

I have written the following code but dont know how to sort the qty prices plz help

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Collections;

public partial class _Default : System.Web.UI.Page
    Table itable;
    TableRow irow;
    TableCell icell;
    protected void Page_Load(object sender, EventArgs e)
        if (!Page.IsPostBack)
            itable = new Table();
    public void create_header()
        irow = new TableRow();
        icell = new TableCell();
        icell.Text = "SKU";
        icell = new TableCell();
        icell.Text = "Title";
        icell = new TableCell();

Where do Custom List Forms get their form element ordering from?

I have been pulling my hair out trying to figure out where Designer gets is column/field ordering from when you insert a custom list form onto a page.  The order (and ever what's rendered) is not what my content type is.  Can anyone please tell me where it gets its order from, or do I just have to be resigned to re-ordering it in html view?  I am trying to create a "perfect" list template so that it can be used repeatedly and always be in the same order.
There are no mistakes; every result tells you something of value about what your are trying to accomplish.
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