Solved

Gridview templatefield sorting

Posted on 2014-01-28
3
379 Views
Last Modified: 2014-02-04
Hi,

I have templatefield as shown below;

<asp:TemplateField HeaderText="Template Name" >
                            <EditItemTemplate>
                                <asp:TextBox ID="txttempName" runat="server" Text='<%# Bind("TEMPLATE_NAME") %>' CssClass="" MaxLength="30"></asp:TextBox>

                            </EditItemTemplate>

                            <ItemTemplate>
                                <asp:Label ID="LabeltempName" runat="server" Text='<%# Bind("TEMPLATE_NAME") %>'></asp:Label>
                                                            </ItemTemplate>
                        </asp:TemplateField>

Now please could help me out as how to implement sorting on this without use of linkbutton or hyperlink.


Thanks in advance...
0
Comment
Question by:mannevenu26
  • 2
3 Comments
 
LVL 16

Expert Comment

by:Easwaran Paramasivam
ID: 39816982
Set the sortexpression to PROPERTY field. Please note that it should not a simple variabale.

Example.
<asp:TemplateField HeaderText="Category" SortExpression="Category">
   <ItemTemplate>A value</ItemTemplate>
</asp:TemplateField>

......

public class yourclass
{
   //Define Category property here
}

Open in new window

0
 

Author Comment

by:mannevenu26
ID: 39817466
What property should i define in this class? can u please give me one example..
0
 
LVL 16

Accepted Solution

by:
Easwaran Paramasivam earned 500 total points
ID: 39817735
What field you bind to the column. Please mention that.

For your reference http://csharpdotnetfreak.blogspot.com/2012/06/sorting-gridview-columns-headers-aspnet.html
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Asp.net mvc foreach 3 32
Memory Usage 2 49
how to read json value 2 27
C# MVC and a global static factory that never dies 4 42
Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
Need to grow your business through quality cloud solutions? With everything required to build a cloud platform and solution, you may feel like the distance between you and the cloud is quite long. Help is here. Spend some time learning about the Con…

943 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

5 Experts available now in Live!

Get 1:1 Help Now