Solved

Gridview templatefield sorting

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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

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 …
Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

758 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

22 Experts available now in Live!

Get 1:1 Help Now