473,395 Members | 1,680 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

web grid not sorting with VB.Net

I've already posted this in the asp forum, and other asp.net forums on the
net with no luck...

I've got a data grid, with paging, and sorting allowed. I can find loads of
examples, and have previous done this, when generating all the data from my
database at run time, progmatically.

Now I'm trying to do it through the design editor, using datasets instead of
dataviews, etc...

is what i'm doing below the wrong approach when attempting this in a "design
time" fashion?
the paging works fine, and i get links correctly for clicking on the title
to sort, but sorting does not work, why?
' ---------- CODE START

' other initialization and delcarations here...

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

If Not Page.IsPostBack Then
' change the page title
Label1.Text = "BIF II ( Avenue ) Logger on " +
System.Environment.MachineName + ". ...Sorting currently not working..."

' Put user code here to initialize the data source
sqldataadapterLogger.Fill(DataSetLogger)
DataGrid1.DataSource = DataSetLogger.AvenueLog.DefaultView
DataGrid1.DataBind()
Session("dataset") = DataSetLogger
Session("pageindex") = 0
Session("sortcolumn") = Nothing
Session("sortascend") = False
End If

End Sub

Private Sub BindData()

DataSetLogger = Session("dataset")
Dim currentPageIndex As Integer = Session("pageindex")
Dim currentSortColumn As String = Session("sortcolumn")
Dim dv As DataView = DataSetLogger.AvenueLog.DefaultView

' apply sorting
If (Not currentSortColumn Is Nothing) Then
If (Session("sortascend") = True) Then
dv.Sort = currentSortColumn + " ASC"
Else
dv.Sort = currentSortColumn + " DESC"
End If

' ************************************************** **
' this label1 is a title, and correctly displays
' the column i click on with the appending ASC/DESC
' to prove the code hits here, and that the sort is
' being set correctly.
' ************************************************** **
Label1.Text = dv.Sort
End If

' apply current page
DataGrid1.CurrentPageIndex = currentPageIndex

' bind data
DataGrid1.DataSource = dv
DataGrid1.DataBind()

End Sub

Private Sub DataGrid1_PageIndexChanged(ByVal source As Object, ByVal e _
As System.Web.UI.WebControls.DataGridPageChangedEvent Args) _
Handles DataGrid1.PageIndexChanged

Session("pageindex") = e.NewPageIndex
BindData()

End Sub
Private Sub DataGrid1_SortCommand(ByVal source As Object, _
ByVal e As System.Web.UI.WebControls.DataGridSortCommandEvent Args)
_
Handles DataGrid1.SortCommand

Session("sortascend") = Not Session("sortascend")
Session("sortcolumn") = e.SortExpression
BindData()

End Sub

' ------------ CODE END

Thanks for your time and help,
in anticipation.
Daniel.
Nov 20 '05 #1
0 1046

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: pmud | last post by:
Hi, I need to display columns in a data grid based on 7 different queries. Now I have 32 questions: 1. Is it possble to have 1 single data adapter with 7 queries & 1 data set or do I need to...
12
by: pmud | last post by:
Hi, I am using teh following code for sorting the data grid but it doesnt work. I have set the auto generate columns to false. & set the sort expression for each field as the anme of that...
1
by: Tj2007_1 | last post by:
I have grid has 10 columns and I want to allow sorting only on first two column. When I do allowsorting = true my all column show as link button. Thanks tj
1
by: puja | last post by:
hi all, am using grid view in asp.net 2.0 . My problem is easy but can't get it to work. My grid view id = grdContract and am binding grid view using dataset My dataset returns 5 columns from...
1
by: =?Utf-8?B?YmJkb2J1ZGR5?= | last post by:
I have a grid view that pulls data from a dbf file. I set the Allow Sorting to true and I put my code in the Sorting event. The problem is that I can't get the sorting to work so I wrote some...
0
by: allan.s.palmer | last post by:
Hi everyone, I have a generic List<that is bound to a grid view and I want to enable sorting. I have enabled sorting on the GridView, and have set my sort expressions for the each property of...
2
by: mrbadboy | last post by:
Hi, Im not able to find where getRowValues() function is defined in the grid framework. Can anybody help me to find where the function is defined or Can anybody explain how getRowValues() works...
15
by: Gilles Ganault | last post by:
Hello Since Python is such a productive language, I'd really like to be able to use it to write GUI apps for Windows, but business apps require rich widgets like (DB)grids, calendars, etc. ...
1
by: mbewers1 | last post by:
Hi there I'm trying to add in sorting for the data grid in my web page but nothing happens when I click on the table headers. I've researched the web and developed the code below and set...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.