Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1175
Sorting on TemplateFields
posted

Hello there,


the user should be able to sort some columns, this can be normal text (names), numbers or dates.

I found this example on your page: http://help.infragistics.com/Help/NetAdvantage/ASPNET/2012.1/CLR4.0/html/WebDataGrid_Sorting.html 

The example just binds directly to the data, in my case, I have Templates as columns:

                   

<ig:TemplateDataField Key="Name" Width="260px">

                       

<HeaderTemplate>

                           

<asp:Label ID="lblNameHeader" runat="server">Name</asp:Label><br>

                       

</HeaderTemplate>

                       

<ItemTemplate>

                           

<asp:LinkButton ID="linkBtnName" runat="server" CausesValidation="False" CommandName="Link"

                               

Width="200px" Font-Underline="true" Style="white-space: pre-wrap;">linkBtnName</asp:LinkButton>

                       

</ItemTemplate>

                       

<FooterTemplate>

                           

<div class="rowSelectEdit">

                               

<stgwc:TextEdit runat="server" ID="txtIndvId" Width="0px" />

                               

<asp:Label runat="server" ID="lblNameEdit" CssClass="lblRequiredField" Style="white-space: pre-wrap;">

                                                           

                               

</asp:Label>

                               

<stgwc:ImageLinkButton ID="ibutChange" runat="server" CssClass="icoButton" ToolTip="Opens a search page where you can find your roles entry."

                                   

CausesValidation="False" ImageUrl="Images/base/Icons/16x16/media_play_green.png"

                                   

CommandName="SearchIndOrgInsert">

                               

</stgwc:ImageLinkButton>

                           

</div>

                       

</FooterTemplate>

                   

</ig:TemplateDataField>

 

In the Code behind, I set the sorting like this:

       

       

private void InitializeSortButtons()

        {

            dgrRoles.Behaviors.CreateBehavior<Infragistics.Web.UI.GridControls.

Sorting>();

            dgrRoles.Behaviors.Sorting.SortingMode =

SortingMode.Single;

            dgrRoles.Behaviors.Sorting.SortedColumns.Add(dgrRoles.Columns[COL_NAME], Infragistics.Web.UI.

SortDirection.Ascending);

            dgrRoles.Behaviors.Sorting.SortedColumns.Add(dgrRoles.Columns[COL_NAME], Infragistics.Web.UI.

SortDirection.Descending);

        }

 

const string COL_NAME = "Name";

 

But I get an error on the preRender:

"An unexpected error occured. Cannot find column Name."

 

 

Am I missing something? Is it possible to sort with the template fields?

 

 

BTW: Is there a possibility to format code better?

 

 

Thanks for your response!

 

Parents Reply Children