Solved

Gridview templatefield sorting

Posted on 2014-01-28
3
383 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Suggested Solutions

Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

730 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