Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Manually sorting and paging a GridView in ASP.NET(VB/VS2k5)

Posted on 2006-11-08
9
Medium Priority
?
463 Views
Last Modified: 2012-05-05
In 2003 i would have a DataGrid tag like this

<asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="True" OnSortCommand="SortCommand_OnClick" OnPageIndexChanged="dgTitles_Paging">

which called this

    Sub dgTitles_Paging(ByVal sender As Object, ByVal e As DataGridPageChangedEventArgs)
      GridView1.CurrentPageIndex = e.NewPageIndex
       BindData()
    End Sub
    Sub SortCommand_OnClick(ByVal Source As Object, ByVal E As DataGridSortCommandEventArgs)
        Label1.Text = "SELECT NCR_ID, ORDER_QTY, REJECTED_DATE from tblMain " & E.SortExpression
        BindData()
    End Sub

This obviously doesn't work in 2005. So how do I manually set up sorting/paging for a GridView in 05?   TIA
0
Comment
Question by:Mike Miller
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
9 Comments
 
LVL 3

Expert Comment

by:Bluford
ID: 17902483
I think you can still do the same thing with a DataGrid in 2005 as you did in 2003, but in the code above you are trying to use GridView.  Change it back to DataGrid and it should work fine.
0
 
LVL 12

Expert Comment

by:sandip132
ID: 17903236
0
 

Author Comment

by:Mike Miller
ID: 17906652
Blu,

I can't just change it back to DataGrid because it's not a datagrid, its a GridView. Is there a datagrid control in 2005?
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:Mike Miller
ID: 17909473
I got it. Here it is...

html...
<asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="True" OnPageIndexChanging="GridView_PageIndexChanging" OnSorting="SortCommand_OnClick">

and the code behind...
    Protected Sub GridView_PageIndexChanging(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewPageEventArgs) Handles GridView1.PageIndexChanging
        GridView1.PageIndex = e.NewPageIndex
        BindData()
    End Sub
    Protected Sub SortCommand_OnClick(ByVal Source As Object, ByVal E As GridViewSortEventArgs)
        Label1.Text = "SELECT NCR_ID, ORDER_QTY, REJECTED_DATE from tblMain ORDER BY " & E.SortExpression
        BindData()
    End Sub


thanks guys

0
 
LVL 3

Expert Comment

by:Bluford
ID: 17912987
Yep that would work.  FYI, the DataGrid control still works in ASP.NET 2.0 and VS 2005.  There is not a DataGrid control listed in the controls toolbar, but you can still use DataGrid if you manually type it in.  There is no particular need to switch everything over to using GridViews, unless you need the enhanced functionality it provides.
0
 

Author Comment

by:Mike Miller
ID: 17914226
I actually tried that before and it wasn't working for me. I just assumed that VS just changed from grid to view. Is there a namespace/reference i need to address to use the grid?
0
 
LVL 3

Expert Comment

by:Bluford
ID: 17918634
There should not be any special references required.  On my system, I can open up a project, go into source view of an .aspx page, and insert the following code:

<asp:DataGrid runat="server" ID="myDataGrid"></asp:DataGrid>

Then I am able to use all the Visual Studio 2005 tools to modify its properties, in both code and design view.
0
 
LVL 1

Accepted Solution

by:
DarthMod earned 0 total points
ID: 17964655
PAQd, 500 points refunded.

DarthMod
CS Moderator
0

Featured Post

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Suggested Courses

715 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question