Sorting on a column that uses TemplateColumn

Discussion in 'ASP .Net Datagrid Control' started by Dan, Apr 4, 2004.

  1. Dan

    Dan Guest

    All,
    In order to make a column a clickable link (with 2 url parameters), I used a
    TemplateColumn with a Hyperlink Item template. That works great. However,
    I would like to be able to sort on that column as well. I am sorting on all
    of the other columns in the datagrid already.

    How can I make this column sortable?

    Code snippet:

    <asp:TemplateColumn HeaderText="Client Name">
    <ItemTemplate>
    <asp:HyperLink Runat=server
    Text='<%# DataBinder.Eval(Container.DataItem,"Client_Name") %>'
    NavigateUrl = '<%# "Client_Details.aspx?EnhId=" +
    DataBinder.Eval(Container.DataItem,"Enhancement_ID") + "&ClientId=" +
    DataBinder.Eval(Container.DataItem,"Client_ID") %>'
    Target=_blank />
    </ItemTemplate>
    </asp:TemplateColumn>
     
    Dan, Apr 4, 2004
    #1
    1. Advertising

  2. Dan

    Teemu Keiski Guest

    Hi,

    if I understood right what you mean, you can specify SortExpression for
    TemplateColumn like for any other column.

    --
    Teemu Keiski
    MCP, Microsoft MVP (ASP.NET), AspInsiders member
    ASP.NET Forum Moderator, AspAlliance Columnist
    http://blogs.aspadvice.com/joteke


    "Dan" <daniel.*NO*chawner@*SPAM*immedient.com> wrote in message
    news:...
    > All,
    > In order to make a column a clickable link (with 2 url parameters), I used

    a
    > TemplateColumn with a Hyperlink Item template. That works great.

    However,
    > I would like to be able to sort on that column as well. I am sorting on

    all
    > of the other columns in the datagrid already.
    >
    > How can I make this column sortable?
    >
    > Code snippet:
    >
    > <asp:TemplateColumn HeaderText="Client Name">
    > <ItemTemplate>
    > <asp:HyperLink Runat=server
    > Text='<%# DataBinder.Eval(Container.DataItem,"Client_Name") %>'
    > NavigateUrl = '<%# "Client_Details.aspx?EnhId=" +
    > DataBinder.Eval(Container.DataItem,"Enhancement_ID") + "&ClientId=" +
    > DataBinder.Eval(Container.DataItem,"Client_ID") %>'
    > Target=_blank />
    > </ItemTemplate>
    > </asp:TemplateColumn>
    >
    >
    >
    >
     
    Teemu Keiski, Apr 6, 2004
    #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. Bob
    Replies:
    0
    Views:
    616
  2. Nus Pieds

    TemplateColumn CheckBox

    Nus Pieds, Jul 16, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    382
    Nus Pieds
    Jul 16, 2003
  3. Edward

    TemplateColumn Width

    Edward, Nov 21, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    1,231
    S. Justin Gengo
    Nov 21, 2003
  4. Maziar Aflatoun

    TemplateColumn with multiple parameters

    Maziar Aflatoun, Jan 3, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    399
  5. Solomon Shaffer

    CommandArgument in TemplateColumn

    Solomon Shaffer, Jan 16, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    704
    Solomon Shaffer
    Jan 16, 2004
Loading...

Share This Page