CodeSmith Community
Your Code. Your Way. Faster!

Question about sorting, searching, and gridviews (images/code included)

Latest post 01-27-2008 8:49 PM by thisbetom. 2 replies.
  • 01-15-2008 3:23 AM

    • thisbetom
    • Not Ranked
    • Joined on 06-27-2007
    • Posts 6
    • Points 150

    Question about sorting, searching, and gridviews (images/code included)

    Hey Board,

     I just spent 20 minutes writing out a post and hit the back button... *bangs head on desk*... Sorry this one is shorter, but I have to get some sleep!

     My question pertains to the following table structure:  http://www.photolava.com/view/cj39.html

    Quick Explanation:
    Members are people within an organization to which "Admins" create Events (AtEvents) for.  They then keep track of people who attend and assign credits to them.

    Generated Code: http://www.photolava.com/view/cj37.html (Note I removed the Hyperlink Navigation Properties from the HyperLinkFields and also changed the default FName to display Email.)

    BEGING COPY OF CODE

    <asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
        <h2>
            At Member Event List</h2>
        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
            <ContentTemplate>
                <data:GridViewSearchPanel ID="GridViewSearchPanel1" runat="server" GridViewControlID="GridView1"
                    PersistenceMethod="Session" />
                <br />
                <data:EntityGridView ID="GridView1" runat="server" AutoGenerateColumns="False" OnSelectedIndexChanged="GridView1_SelectedIndexChanged"
                    DataSourceID="AtMemberEventDataSource" DataKeyNames="MemberUid, EventUid" AllowMultiColumnSorting="false"
                    DefaultSortColumnName="" DefaultSortDirection="Ascending" ExcelExportFileName="Export_AtMemberEvent.xls">
                    <Columns>
                        <asp:CommandField ShowSelectButton="True" ShowEditButton="False" />
                        <data:HyperLinkField HeaderText="Member" DataContainer="MemberUidSource" DataTextField="Email"
                            SortExpression="MemberUID" />
                        <data:HyperLinkField HeaderText="Event" DataContainer="EventUidSource" DataTextField="EventName" SortExpression="EventUID" />
                        <asp:BoundField DataField="CreditEarned" HeaderText="Credit Earned" SortExpression="CreditEarned" />
                    </Columns>
                    <EmptyDataTemplate>
                        <b>No AtMemberEvent Found!</b>
                    </EmptyDataTemplate>
                </data:EntityGridView>
                <br />
                <asp:Button runat="server" ID="btnAtMemberEvent" OnClientClick="BLOCKED SCRIPTlocation.href='AtMemberEventEdit.aspx'; return false;"
                    Text="Add New"></asp:Button>
            </ContentTemplate>
        </asp:UpdatePanel>
        <data:AtMemberEventDataSource ID="AtMemberEventDataSource" runat="server" SelectMethod="GetPaged"
            EnablePaging="True" EnableSorting="True" EnableDeepLoad="True">
            <DeepLoadProperties Method="IncludeChildren" Recursive="False">
                <Types>
                    <data:AtMemberEventProperty Name="AtEvent" />
                    <data:AtMemberEventProperty Name="AtMember" />
                </Types>
            </DeepLoadProperties>
            <Parameters>
                <data:CustomParameter Name="WhereClause" Value="" ConvertEmptyStringToNull="false" />
                <data:CustomParameter Name="OrderByClause" Value="" ConvertEmptyStringToNull="false" />
                <asp:ControlParameter Name="PageIndex" ControlID="GridView1" PropertyName="PageIndex"
                    Type="Int32" />
                <asp:ControlParameter Name="PageSize" ControlID="GridView1" PropertyName="PageSize"
                    Type="Int32" />
                <data:CustomParameter Name="RecordCount" Value="0" Type="Int32" />
            </Parameters>
        </data:AtMemberEventDataSource>
    </asp:Content>

    END COPY OF CODE 

     

    Now for the questions at hand (please note that these may not seem pertinant for this example, but they come up other places in the code... I just tried to get it down to a simple implimentation that demonstrated both for purposes of this post):

    1. Assuming they add 20 events and have ~200 users (and growing)... This table should be a doosey!  If you look at the generated page, There is no way to search and/or drill down on this table by Member Email.  What is the best way to impliment this into the search bar on the top?

    2. Assuming you currently click sort on either Event or Member, it sorts by the GUID instead of the displayed field.  If I replace the GUID sort expression above, I get an "Invalid Coumn Name 'Email'" exception (because the column is in an object/table other than the one in the gridview/datasource).  How do I get the gridView to sort by Email out of the member table?

     I know either of these can beaccomplishedwith another workaround (custom controls, querystrings, etc...) but I feel like I'm just missing something.

    Thanks in Advance!!!

     -Tom

    • Post Points: 35
  • 01-17-2008 8:33 PM In reply to

    Re: Question about sorting, searching, and gridviews (images/code included)

    i have the same problem here...Does ANYONE from NETTIERS even read these anymore??? I see many many unaswered posts here...Love the product but am felling let down on the goal line??!?!?!?!?!

    • Post Points: 35
  • 01-27-2008 8:49 PM In reply to

    • thisbetom
    • Not Ranked
    • Joined on 06-27-2007
    • Posts 6
    • Points 150

    Re: Question about sorting, searching, and gridviews (images/code included)

    Reply |Contact |Answer

    Eventually I just created a view with the separate information pulled out as strings and then built the project, change the datasource for the gridview, and removed everything relating to Deepload.

     

    Then you change all your fields to BoundFields and/or remove the other DataContainter References.

     BEGIN NEW CODE FOR REFERENCE


    <asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
        <h2>
            At Member List</h2>
        <data:GridViewSearchPanel ID="GridViewSearchPanel1" runat="server" GridViewControlID="GridView1"
            PersistenceMethod="Session" />
        <br />
        <data:EntityGridView ID="GridView1" runat="server" AutoGenerateColumns="False" OnSelectedIndexChanged="GridView1_SelectedIndexChanged"
            DataSourceID="VwAdminMemberListDataSource" DataKeyNames="Uid" AllowMultiColumnSorting="false"
            DefaultSortColumnName="" DefaultSortDirection="Ascending" ExcelExportFileName="Export_AtMember.xls">
            <Columns>
                <asp:CommandField ShowSelectButton="True" ShowEditButton="False" />
                <data:HyperLinkField DataTextField="FullName" HeaderText="FullName" SortExpression="FullName"
                    DataNavigateUrlFormatString="AtMemberEdit.aspx?UID={0}" DataNavigateUrlFields="Uid" />
                <asp:BoundField DataField="Phone" HeaderText="Phone" SortExpression="Phone" />
                <asp:BoundField DataField="Address" HeaderText="Address" SortExpression="Address" />
                <asp:BoundField DataField="City" HeaderText="City" SortExpression="City" />
                <asp:BoundField DataField="State" HeaderText="State" SortExpression="State" />
                <asp:BoundField DataField="Zip" HeaderText="Zip" SortExpression="Zip" />
                <asp:BoundField DataField="Major" HeaderText="Major" SortExpression="Major" />
                <asp:BoundField DataField="ATClass" HeaderText="AT Class" SortExpression="ATClass" />
                <asp:BoundField DataField="ATFamily" HeaderText="AT Family" SortExpression="ATFamily" />
                <asp:BoundField DataField="MemberStatus" HeaderText="Member Status" SortExpression="MemberStatus" />
                <asp:BoundField DataField="ATStatus" HeaderText="AT Status" SortExpression="ATStatus" />
                <data:BoundRadioButtonField DataField="IsGoodFinance" HeaderText="Is Good Finance"
                    SortExpression="[IsGoodFinance]" />
            </Columns>
            <EmptyDataTemplate>
                <b>No AtMember Found!</b>
            </EmptyDataTemplate>
        </data:EntityGridView>
        <br />
        <asp:Button runat="server" ID="btnAtMember" OnClientClick="BLOCKED SCRIPTlocation.href='AtMemberEdit.aspx'; return false;"
            Text="Add New"></asp:Button>
        <data:VwAdminMemberListDataSource ID="VwAdminMemberListDataSource" runat="server"
            SelectMethod="GetPaged" EnablePaging="True" EnableSorting="True">
            <Parameters>
                <data:CustomParameter Name="WhereClause" Value="" ConvertEmptyStringToNull="false" />
                <data:CustomParameter Name="OrderByClause" Value="" ConvertEmptyStringToNull="false" />
                <asp:ControlParameter Name="PageIndex" ControlID="GridView1" PropertyName="PageIndex"
                    Type="Int32" />
                <asp:ControlParameter Name="PageSize" ControlID="GridView1" PropertyName="PageSize"
                    Type="Int32" />
                <data:CustomParameter Name="RecordCount" Value="0" Type="Int32" />
            </Parameters>
        </data:VwAdminMemberListDataSource>
    </asp:Content>

    END NEW CODE FOR REFERENCE 

    -Tom 

    • Post Points: 5
Page 1 of 1 (3 items) | RSS
Copyright © 2008 CodeSmith Tools, LLC
Powered by Community Server (Commercial Edition), by Telligent Systems