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 April 11th, 2006, 11:55 PM
Authorized User
 
Join Date: Dec 2003
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to ysiline Send a message via Yahoo to ysiline
Default DataGrig doesn't remeber sort command

May anyone help me that my grid always lost the memory of sorting based on a
specific column when I clicked to move to next page index.

My DataGrid1:
===============
<asp:datagrid id="DataGrid1" runat="server" AllowSorting="True"
AutoGenerateColumns="False" OnItemDataBound="Custom_Bound"
HorizontalAlign="Left" GridLines="Vertical" BorderColor="LightGray" BackColor="White" PageSize="1" Height="70px" Width="601px" OnPageIndexChanged="My_Page" AllowPaging="True" Font-Size="X-Small" OnSortCommand="DoSortCommand">
           <HeaderStyle Font-Bold="True" ForeColor="MediumBlue"
BackColor="Gainsboro"></HeaderStyle>
           <PagerStyle Mode="NumericPages"></PagerStyle>
           <EditItemStyle BorderColor="#404040"></EditItemStyle>
           <AlternatingItemStyle ForeColor="Black"></AlternatingItemStyle>
           <ItemStyle BorderWidth="1px" ForeColor="Black"
BorderStyle="Solid" BorderColor="#404040"></ItemStyle>
           <Columns>
                <asp:BoundColumn .....
                <asp:BoundColumn .....
                <asp:BoundColumn .....
                <asp:BoundColumn .....
         </Columns>
</asp:datagrid>

The code is below:
================
Dim Adp as new oledbadapter
Dim Conn as new oledbconnection
Dim Dset as new DataSet
Dim Dv as new DataView
Dim CurSortExp as string

Sub My_Page(sender As Object, e As DataGridPageChangedEventArgs)
     if CurShortExp<>"" then dv.sort=CurShortExp
    DataGrid1.CurrentPageIndex = e.NewPageIndex
    BindGrid(true)
end sub

Sub Showdata
    DataGrid1.Visible=True
    DataGrid1.DataSource=dv
    if CurShortExp<>"" then dv.sort=CurShortExp
    DataGrid1.DataBind()
End sub

sub DoSortCommand(s as object,e as DataGridSortCommandEventArgs)
     BindGrid(true)
    CurShortExp=e.SortExpression
    dv.sort=e.SortExpression
    showdata
end sub

Sub BindGrid(optional PageMoved as boolean = false)
    Conn= new oledbconnection .......
    Adp= new oledbadapter......
    Adp.Fill(Dset,"mydata")
    Dv.Table=Dset.Tables("mydata")
    if Dset.Tables(0).Rows.Count>=0 then
        showdata
    else
        response.write("No record")
    end if
    Conn.Close()
End sub

===================

  Thanks





Similar Threads
Thread Thread Starter Forum Replies Last Post
Dynamic sort order or sort datatype kapy_kal XSLT 2 September 18th, 2007 02:10 PM
Command text was not set for the command object Sheraz Khan Classic ASP Databases 2 May 29th, 2007 12:57 AM
how to sort cross tab.sort based on row total joxa83 Crystal Reports 7 March 2nd, 2006 09:12 AM
Unable to sort using xsl sort command sly_jimmy_boy XSLT 3 June 17th, 2005 05:15 AM





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