in

CodeSmith Community

Your Code. Your Way. Faster!

How to sort with EntityGridView and entity DataSource

Last post 02-21-2007 9:20 AM by swin. 1 replies.
Page 1 of 1 (2 items)
Sort Posts: Previous Next
  • 02-21-2007 8:55 AM

    • peschkaj
    • Not Ranked
    • Joined on 02-14-2007
    • Posts 4
    • Points 120

    How to sort with EntityGridView and entity DataSource

    I am attempting to pull from a SQL Server database using the strongly typed datasource generated by CodeSmith.  Paging is working correctly, however I cannot seem to get sorting to work.

    Thanks in advance,

    jeremiah 

    Here is the code in question:

     

    <cc1:DistrictDataSource ID="DistrictDataSource1" EnablePaging="true" runat="server" EnableSorting="True" Sort="DistrictName">
            <Parameters>
                <asp:ControlParameter Name="PageIndex" ControlID="EntityGridView1" PropertyName="PageIndex" Type="Int32" />
                <cc1:CustomParameter Name="OrderByClause" Value="" ConvertEmptyStringToNull="false" />
                <cc1:CustomParameter Name="RecordCount" Value="0" Type="Int32" />
            </Parameters>
            <DeepLoadProperties Method="IncludeChildren" Recursive="False">
            </DeepLoadProperties>
        </cc1:DistrictDataSource>
       
        <cc2:EntityGridView
            ID="EntityGridView1"
            runat="server"
            AutoGenerateColumns="False"
            DataSourceID="DistrictDataSource1"
            DataKeyNames="DistrictID"
            AllowMultiColumnSorting="False"
            AllowPaging="True"
            AllowSorting="True"
            EnableViewState="False" PageSize="20"
            AllowExportToExcel="False"
            DefaultSortColumnName="DistrictName"
            DefaultSortDirection="Ascending"
            ExportToExcelText="Excel"
            PageSelectorPageSizeInterval="10"
            EnableTheming="False">
            <Columns>
                <asp:HyperLinkField DataNavigateUrlFields="DistrictID" DataNavigateUrlFormatString="../District/BuildingList.aspx?DistrictID={0}"
                    DataTextField="DistrictName" HeaderText="District" SortExpression="DistrictName" />
                <asp:BoundField DataField="DistrictID" HeaderText="DistrictID" ReadOnly="True" SortExpression="DistrictID"
                    Visible="False" />
            </Columns>
           
           
        </cc2:EntityGridView>
     

    • Post Points: 35
  • 02-21-2007 9:20 AM In reply to

    • swin
    • Top 10 Contributor
    • Joined on 06-14-2006
    • London, UK
    • Posts 921
    • Points 34,675

    Re: How to sort with EntityGridView and entity DataSource

    Have you tried setting the SelectMethod on the datasource to "GetPaged"?

     
    hth

    swin 

    -------------------------------------------------
    Member of the .NetTiers team
    -------------------------------------------------
    • Post Points: 5
Page 1 of 1 (2 items)
Copyright © 2008 CodeSmith Tools, LLC
Powered by Community Server (Commercial Edition), by Telligent Systems