Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Datagrid Control > Grid fails to sort by column when pagging

Reply
Thread Tools

Grid fails to sort by column when pagging

 
 
mkhmer
Guest
Posts: n/a
 
      04-20-2006
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


 
Reply With Quote
 
 
 
Reply

Thread Tools

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Cross-browser problem | XML pagging kaddison01@gmail.com XML 1 02-21-2007 05:20 PM
Cross-browser problem | XML pagging kaddison01@gmail.com Javascript 0 02-21-2007 03:29 PM
Double Bubble Sort Algorithm Fails to Sort AT ALL Protoman C++ 8 04-05-2006 01:22 PM
How to know if a datagrid item will be displayed in a datagrid with pagging CFirmino ASP .Net Datagrid Control 1 04-04-2004 12:39 AM
Ado sort error-Ado Sort -Relate, Compute By, or Sort operations cannot be done on column(s) whose key length is unknown or exceeds 10 KB. Navin ASP General 1 09-09-2003 07:16 AM



Advertisments