Grid doesn't short when moving to next page index

Discussion in 'ASP .Net Datagrid Control' started by mkhmer, Apr 10, 2006.

  1. mkhmer

    mkhmer Guest

    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
     
    mkhmer, Apr 10, 2006
    #1
    1. Advertising

  2. mkhmer

    babu Guest

    mkhmer wrote:
    > 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
     
    babu, Apr 10, 2006
    #2
    1. Advertising

  3. mkhmer

    mkhmer Guest

    No idea? Just repond with blank content????

    (^_^) seeking for further help now.



    "babu" <> wrote in message
    news:...
    >
    > mkhmer wrote:
    >> 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

    >
     
    mkhmer, Apr 12, 2006
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Deniz Bahar
    Replies:
    2
    Views:
    502
    Andrey Tarasevich
    Mar 9, 2005
  2. David Geering

    longs, long longs, short short long ints . . . huh?!

    David Geering, Jan 8, 2007, in forum: C Programming
    Replies:
    15
    Views:
    581
    Keith Thompson
    Jan 11, 2007
  3. Replies:
    4
    Views:
    857
    Kaz Kylheku
    Oct 17, 2006
  4. Ioannis Vranos

    unsigned short, short literals

    Ioannis Vranos, Mar 4, 2008, in forum: C Programming
    Replies:
    5
    Views:
    718
    Eric Sosman
    Mar 5, 2008
  5. Tomasz Chmielewski

    sorting index-15, index-9, index-110 "the human way"?

    Tomasz Chmielewski, Mar 4, 2008, in forum: Perl Misc
    Replies:
    4
    Views:
    337
    Tomasz Chmielewski
    Mar 4, 2008
Loading...

Share This Page