I am trying to sort the grid display using the Name property but it does not work and the Grid is unsorted. I am using the 3 attributes of DisplayColumn. Any ideas of what is wrong?
namespace BBLDSAccessManager.DAL
{
[MetadataType(typeof(PositionMetaData))]
[DisplayColumn("Name","Name", false)]
public partial class Position
{
public class PositionMetaData
{
[DisplayName("Position Name")]//shows in the header of grid
[ScaffoldColumn(true)]
public object Name { get; set; }
}
}
}
[MetadataType(typeof(PositionMetaData))]
[DisplayColumn("Name","Name", false)]
[DisableEditing(true)]
public partial class Position
{
internal class PositionMetaData
{
}
}
this should work, not I embed the Metadata/buddy class insed the partial and make it internal so it does not showup anywhere else as we only really need this for the attributes.
See my blog C# Bits | Twitter @sjnaughton Always seeking an elegant solution.
Member
18 Points
156 Posts
DisplayColumn sort is not working
Sep 27, 2012 12:47 PM|pallone|LINK
Hi,
I am trying to sort the grid display using the Name property but it does not work and the Grid is unsorted. I am using the 3 attributes of DisplayColumn. Any ideas of what is wrong?
Member
18 Points
156 Posts
Re: DisplayColumn sort is not working
Sep 28, 2012 03:56 AM|pallone|LINK
Hi,
Does DisplayColumn only work for foreign keys?
What I would like to do is sort the grid when the page first load by Name ascending and Name is not a foreign key.
Please note that I am using Dynamic Data.
How can I achive that?
Cheers
C
All-Star
94130 Points
18109 Posts
Re: DisplayColumn sort is not working
Sep 28, 2012 08:45 PM|Decker Dong - MSFT|LINK
Yes, please see:http://msdn.microsoft.com/en-us/library/system.componentmodel.dataannotations.displaycolumnattribute.aspx
Member
18 Points
156 Posts
Re: DisplayColumn sort is not working
Sep 29, 2012 06:24 AM|pallone|LINK
Hi,
So how do I sort the grid dynamically when the page List.aspx loads?
Cheers,
CP
All-Star
17916 Points
5681 Posts
MVP
Re: DisplayColumn sort is not working
Oct 02, 2012 04:45 AM|sjnaughton|LINK
Hi Pallone, see my articel here Setting the Initial Sort Order – Dynamic Data
Always seeking an elegant solution.
Member
18 Points
156 Posts
Re: DisplayColumn sort is not working
Oct 03, 2012 06:20 AM|pallone|LINK
Hi Steve,
Thanks for the link the sort is workin now.
I am also having a look at another tutorial regarding attributes - "DisableEditingAttribute".
However, I cannot figure out where in my page to add the code and how to use it.
Ffor example, in my page load I have added the following code:
I have also a class called DisableEditingAttribute.cs where I added the code for the attribute as you showed in the article.
My partial class looks like that at the moment.
Please could you clarify the following:
1 - Where do I add the DisableEditingAttribute in my partial class
2 - Could you please clarify if this will disable the link to Edit the entity in the GridView?
3 - If I want to disable the Delete link instead, could I use the same code?
Would it be possible for you to put a simple sample together to show how to use your attributes?
Cheers,
CP
All-Star
17916 Points
5681 Posts
MVP
Re: DisplayColumn sort is not working
Oct 04, 2012 12:35 PM|sjnaughton|LINK
Sorry my Bad :( here you go
this should work, not I embed the Metadata/buddy class insed the partial and make it internal so it does not showup anywhere else as we only really need this for the attributes.
Always seeking an elegant solution.