Gridview Header Template sorting

Discussion in 'ASP .Net Web Controls' started by Felix Wafytech, Jun 19, 2006.

  1. Hello All,

    I have a Gridview with a Header Template on one of the columns. I would like
    to sort by this column. How do I accomplish that? Any help is very much
    appreciated.

    Note: I'm able to get the sorting to work in all the other columns.

    Thanks in advance,
    Felix.J
    Felix Wafytech, Jun 19, 2006
    #1
    1. Advertising

  2. Hi Felix,

    Thank you for your post.

    Based on my understanding, the issue is: You are using a Header Template in
    one of the TemplateField column and want to know how to sort by that column
    in GridView. If I've misunderstood anything, please feel free to post here.

    I think all you need to do is make sure that there's a control in the
    Header Template that have correct CommandName and CommandArgument set, for
    example:

    <asp:TemplateField>
    <ItemTemplate>
    <%#Eval("ProductName") %>
    </ItemTemplate>
    <HeaderTemplate>
    <asp:LinkButton ID="link1" runat="server" CommandName="Sort"
    CommandArgument="ProductName" Text="Hello"></asp:LinkButton>
    </HeaderTemplate>
    </asp:TemplateField>

    The key properties is that we set CommandName="Sort", and
    CommandArgument="ProductName" which is the bound field name.

    Hope this helps. Please feel free to post here if anything is unclear.

    Regards,
    Walter Wang
    Microsoft Online Community Support

    ==================================================
    When responding to posts, please "Reply to Group" via your newsreader so
    that others may learn and benefit from your issue.
    ==================================================

    This posting is provided "AS IS" with no warranties, and confers no rights.
    Walter Wang [MSFT], Jun 20, 2006
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. ypul

    sorting on template header

    ypul, Dec 6, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    336
  2. =?Utf-8?B?RG9ydGU=?=
    Replies:
    0
    Views:
    4,571
    =?Utf-8?B?RG9ydGU=?=
    Dec 14, 2005
  3. Liming

    Custom GridView Header and sorting

    Liming, Oct 2, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    360
    Liming
    Oct 2, 2006
  4. Replies:
    0
    Views:
    604
  5. mlt
    Replies:
    2
    Views:
    828
    Jean-Marc Bourguet
    Jan 31, 2009
Loading...

Share This Page