Advertisement

06.10.2007 at 05:09PM PDT, ID: 22625065
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

6.4

Gridview Column Sort Direction

Asked by Hojoformo in C# Programming Language

Tags: ,

How can change the sort direction on a GridView column?  I want to be able to just click on a gridview column header to change the sort direction.  Right now it will only sort asc.  

Col1  Col2  Col3       ---> I want to be able to sort the column.
  2      331  900.00
  3      333  940.00


<asp:GridView ID="dgd_Alerts" runat="server"
        AllowPaging="True"
        AllowSorting=true
        AutoGenerateColumns="False"
        datakeynames="USER_ACCT_ALERT_ID,ALERT_TYPE_ID,ALERT_OPER_ID"  
        BackColor="#CCCCCC"  
        OnRowCancelingEdit="Row_Cancel"
        OnPageIndexChanging="gridView_PageIndexChanging"  
        OnRowCommand="Row_Selected"
        onrowupdated="Row_Updated"
         OnRowEditing="Row_Editing"
        OnRowUpdating="Row_Updating"
        OnRowDeleting="RowDeleting"
        onsorting="GridView_Sorting"

        PagerStyle-CssClass="PagerRowStyle"  
        PagerSettings-Mode="NumericFirstLast"  
        PagerSettings-PageButtonCount="5"
        Width="476px"
        AutoGenerateEditButton="True"
        AutoGenerateDeleteButton="True"  >
        <Columns>
            <asp:BoundField DataField="ALERT_TYPE_TEXT" SortExpression="ALERT_TYPE_TEXT" HeaderText="Type" ReadOnly=True/>
            <asp:BoundField DataField="ALERT_OPER_TEXT"  SortExpression="ALERT_OPER_TEXT" HeaderText="Operator"  ReadOnly=True/>
            <asp:TemplateField HeaderText="Threshold" SortExpression="ALERT_THRESHOLD_AMT">
                <EditItemTemplate>
                    <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("ALERT_THRESHOLD_AMT") %>'></asp:TextBox>
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="Label1" runat="server" Text='<%# Bind("ALERT_THRESHOLD_AMT") %>'></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:BoundField DataField="USER_ACCT_ALERT_ID"  Visible="False" />
            <asp:BoundField DataField="ALERT_TYPE_ID" Visible="False"  />
            <asp:BoundField DataField="ALERT_OPER_ID" Visible="False" />
         
        </Columns>
        <HeaderStyle BackColor=Black />
            <PagerSettings Mode="NumericFirstLast" PageButtonCount="5" />
            <PagerStyle CssClass="PagerRowStyle" />
    </asp:GridView>

protected void GridView_Sorting(object sender, GridViewSortEventArgs e)
        {
            GetViewState();


            if (dsAlertCriteria != null)
            {
                DataView dataView = new DataView(dsAlertCriteria);
                dataView.Sort = e.SortExpression + " " + ConvertSortDirectionToSql(e.SortDirection);

                dgd_Alerts.DataSource = dataView;
                dgd_Alerts.DataBind();

            }
        }
Start Free Trial
[+][-]06.10.2007 at 11:55PM PDT, ID: 19256227

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: C# Programming Language
Tags: gridview, sort
Sign Up Now!
Solution Provided By: Fareed
Participating Experts: 1
Solution Grade: C
 
 
[+][-]06.12.2007 at 06:13AM PDT, ID: 19265772

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20081112-EE-VQP-44