Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.0 and 1.1 Basics
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old April 11th, 2006, 11:55 PM
Authorized User
 
Join Date: Dec 2003
Location: Phnom Penh, KH, Cambodia.
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
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 03:44 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.