Wrox Programmer Forums
|
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 26th, 2006, 11:35 AM
Authorized User
 
Join Date: Jan 2006
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
Default How to sort a column in data grid:

How to sort a column in data grid:

I want to sort on the column "LoanNumber"

In my ASP code shown below, I added AllowSorting property to True, in the
DataGrid.Which gives me the hyperlink in the header.
In order to have this happen I need to do two things: create a
sort event handler and specify the event handler for the
DataGrid's sort event.

I created the sub SortEventHandler as below but I am lost as to
what is next to do?



Sub SortEventHandler(sender as Object, e as DataGridSortCommandEventArgs)
   ...
End Sub


<asp:datagrid id="DG1" runat="server" BackColor="Gainsboro" AutoGenerateColumns="false"
OnItemCommand="DGColumnBtn"
        Width="512px" AllowSorting="True">
        <EditItemStyle BackColor="Red"></EditItemStyle>
        <AlternatingItemStyle BackColor="#C0FFFF"></AlternatingItemStyle>
        <HeaderStyle BackColor="Silver"></HeaderStyle>
        <AlternatingItemStyle BackColor="White" />
    <Columns>
    <asp:ButtonColumn Text="Details" HeaderText="Credit Life" ButtonType="PushButton" />
    <asp:BoundColumn DataField="clid" Visible="False" />
    <asp:BoundColumn DataField="CLMaturityDate" DataFormatString="{0:MM-dd-yyyy}" HeaderText="MAT Date" />
    <asp:BoundColumn DataField="LoanNumber" HeaderText="LoanNumber" SortExpression="LoanNumber" />
    <asp:BoundColumn DataField="Loanamount" HeaderText="Amount" />
    </Columns>
    </asp:datagrid></form>




 Private Sub DG1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DG1.SelectedIndexChanged

    End Sub



 
Old January 26th, 2006, 02:03 PM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
Default

Check this article:
http://samples.gotdotnet.com/quickst..._datagrid.aspx

Jim






Similar Threads
Thread Thread Starter Forum Replies Last Post
export data grid hyperlink column to excel phyzie VS.NET 2002/2003 0 April 16th, 2007 01:45 AM
How to sort data in a data grid? zaheerabbas.sk ASP.NET 1.0 and 1.1 Basics 3 April 10th, 2007 02:37 PM
How do you make a Data Grid Hyperlink Column pass KarmenC ASP.NET 1.x and 2.0 Application Design 5 January 13th, 2005 11:43 AM
Data Grid Drop Down List Column bmains ASP.NET 1.0 and 1.1 Professional 4 September 21st, 2004 08:39 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.